On Wed, 5 Nov 2003, Dillon, John wrote:

> I want to show a number from a database in the format x,xxx.00 in a
> textfield, then if it is changed by the user I want to post the value of the
> number to a decimal field.  However, once you number_format the number it
> becomes a string, and numbers like 3,379.90 give a value of 3 when posted to
> the database, which is hinted at in the notes on number_format.  I suppose I
> need a string to number function - can someone tell me what this might be
> called please?

 I use this:

      $x['funds'] = (int)preg_replace("/[\$,]/","",$x['funds']);

 where $x['funds'] contains something like $3,249,555.32, and the end
 result is an int of 3249555.  I drop the cents... you want to keep 'em,
 change "int" to "float".

Beckman
---------------------------------------------------------------------------
Peter Beckman                                                  Internet Guy
[EMAIL PROTECTED]                             http://www.purplecow.com/
---------------------------------------------------------------------------

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

Reply via email to