Re: number_format

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Floyd Resler <fresler@xxxxxxxxxxxxx>:

In the previous version of PHP we were using, I could pass a string to number_format and it would just change it to a 0 without complaint. With 5.3.6 I get an "expects double" error. I don't suppose there's a way to make it work like it used to??? I'm dealing with really old code that wasn't very well structured.

The way I would get around this would be to create a function like this:

function my_number_format($number, $decimals = 0, $dec_point = '.', $thousands_sep = ',') {
   $number += 0;  //convert value to a number.
   return number_format($number, $decimals, $dec_point, $thousands_sep);
}

The just do a global replace of number_format with my_number_format.

That should work, although I haven't tested it...

Ken


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux