Re: Quick question on data formatting

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2007-11-28 at 22:19 -0700, Jon Westcot wrote:
> Hi all:
> 
>     Since I'm relatively new to PHP, I'm not familiar with all of the shortcuts and efficient ways one could write a routine that handles converting data from one format into another, so I thought I'd ask here for recommendations on how to solve one particular issue I've got.  I'm viewing this as a learning experience for me.
> 
>     I've got some text fields coming in that need to be added to a table as numeric fields.  In particular, I've got to process dollar amounts that appear with dollar signs and commas into their strictly numeric forms.  For example:
> 
>     $123,456.78  becomes 123456.78
>     $24,680  becomes  24680
>     1234B  becomes  1234

$number = ereg_replace( '[^[:digit:].]', '' );

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux