|
Posted by David Haynes on 03/10/06 23:43
laredotornado@zipmail.com wrote:
> Hi,
>
> I have a string value, "1,250" (one thousand, two hundred and fifty).
> Is there a PHP function I can apply to this string that will give me
> the value 1250 in a variable? I've tried "intval", but I get a value
> of 1 (one), at least in PHP 4.
>
> Thanks for any help, - Dave
>
<?php
$foo = "1,250";
$bar = intval(str_replace(',', '', $foo) );
printf("foo = %s, bar = %d\n", $foo, $bar);
?>
-david-
Navigation:
[Reply to this message]
|