]> granicus.if.org Git - php/commitdiff
added money_format() function
authorHartmut Holzgraefe <hholzgra@php.net>
Fri, 2 Aug 2002 10:08:53 +0000 (10:08 +0000)
committerHartmut Holzgraefe <hholzgra@php.net>
Fri, 2 Aug 2002 10:08:53 +0000 (10:08 +0000)
this is similar to C-libs strfmon(), using the same format string
semantics but a different function prototype, so i decided to
give it a more speaking name similar to number_format()

ext/standard/basic_functions.c
ext/standard/config.m4
ext/standard/php_string.h
ext/standard/string.c

index ebafd20e30ff220515d110f99011eeecc8e71ab1..24df4bf049fe4219a0abcfcc32f70458f6d8442a 100644 (file)
@@ -321,6 +321,10 @@ function_entry basic_functions[] = {
        PHP_FE(strcoll,                                                                                                                 NULL)
 #endif
 
+#ifdef HAVE_STRFMON
+       PHP_FE(money_format,                                                    NULL)
+#endif
+
        PHP_FE(substr,                                                                                                                  NULL)
        PHP_FE(substr_replace,                                                                                                  NULL)
        PHP_FE(quotemeta,                                                                                                               NULL)
index 89ddabeda17cf78d797c6d8994f4d2f9e868b662..8fc91f6bc2f2dd6b72bfad5a9ec62d8fd7020968 100644 (file)
@@ -227,6 +227,8 @@ AC_ARG_WITH(regex,
        
 AC_CHECK_FUNCS(fnmatch glob)
 
+AC_CHECK_FUNCS(strfmon)
+
 if test "$PHP_SAPI" = "cgi"; then
   AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])
 fi
index eb6330c34b9bf216665cc0686494625202921898..d63f91b2549b5c88c9998796a0c03ed66e603df1 100644 (file)
@@ -85,7 +85,9 @@ PHP_FUNCTION(sscanf);
 #ifdef HAVE_STRCOLL
 PHP_FUNCTION(strcoll);
 #endif
-
+#if HAVE_STRFMON
+PHP_FUNCTION(money_format);
+#endif
 
 #if defined(HAVE_LOCALECONV) && defined(ZTS)
 PHP_MINIT_FUNCTION(localeconv);
index 499eed7ee4d3fc82697d2d7702248c8280569ab8..0940eab539785b42e19e9e222090b240dce8b580 100644 (file)
@@ -3904,6 +3904,28 @@ PHP_FUNCTION(str_rot13)
 /* }}} */
 
 
+#if HAVE_STRFMON
+/* {{{ proto string money_format(string format , float value)
+   Convert monetary value(s) to string */
+
+PHP_FUNCTION(money_format) {
+       int format_len, str_len = 1024;
+       char *format, *str = emalloc(str_len);
+       double value;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sd",
+                                                         &format, &format_len, &value) == FAILURE) {
+               return;
+       }
+
+       str_len = strfmon(str, str_len, format, value);         
+
+       RETURN_STRINGL(erealloc(str, strlen), str_len, 0);
+}
+
+/* }}} */
+#endif
+
 /*
  * Local variables:
  * tab-width: 4