chads2k2 wrote:btw laser, you don't need it to be in a string for typecast to work. It will work without it being a string.
No it won't. At least not in PHP 5.1. If you create a var as an number starting with 0, it is an octal, and if it isn't valid, at least PHP 5.1 converts it to int(0). 09 isn't a valid octal... octals are base 8 and contain only digits 0-7.
And even then if you have a valid octal, it is converted to the base 10 equivalent, which is only the "same" as the octal symbol for 0-7, as laserlight pointed out because 10 (base8) = 8 (base10).
PowerBook-G4:~ dreamscape$ php -a
Interactive mode enabled
php > $var = 09;
php > echo number_format($var);
php > echo (int)$var;
php > echo (float)$var;
php > echo (string)$var;
php > // what is var?
php > var_dump($var);
int(0)
php >
I think as laserlight suggested, typecasting from a numeric string would be the best way, though I wouldn't cast it to an integer unless you know with absolute certainly the value will always be "integer". I would cast it as floating point without knowing this for certain.
PowerBook-G4:~ dreamscape$ php -a
Interactive mode enabled
php > echo (float)'09';
9
php > echo (float)'09.99';
9.99
php >