From: "Jay Blanchard" <[EMAIL PROTECTED]>
> From: "Diana Castillo" <[EMAIL PROTECTED]>
>
> > [snip]
> > what is the easiest way to convert a string like this "1,300.99" to a
> > number?
> > [/snip]
>
> http://www.php.net/settype

That'll just result in the number 1, though, since the conversion to "float"
will stop at the comma.

If you know that it's just going to be commas in there, a simple
str_replace(',','',$number) will get rid of the commas. Then PHP's type
juggling will take care of the rest for you and treat it like a FLOAT if it
needs to be. Or you can then use settype() to ensure it's a float.

---John Holmes...

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

Reply via email to