Great answer... One question though, how would you convert it back to 
X,xxx.00 format??



-----Original Message-----
From: Peter Beckman [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 05, 2003 10:48 AM
Subject: Re: [PHP-DB] number_format problem

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".

Peter Beckman                                                  Internet Guy
[EMAIL PROTECTED]                   

PHP Database Mailing List ( To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to