Re: number_format

From: Date: Mon, 19 Dec 2011 16:35:33 +0000
Subject: Re: number_format
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-316065@lists.php.net to get a copy of this message
Quoting Floyd Resler <fresler@adex-intl.com>:
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

« previous php.general (#316065) next »