Forum Moderators: coopster

Message Too Old, No Replies

trim all non int char

         

Gruessle

7:57 am on Mar 30, 2005 (gmt 0)

10+ Year Member



I have form where the user enters a number and I store it as an int in mysql.

But when I recall the number I format it as currency with

setlocale(LC_MONETARY, 'en_US');
$number = money_format('%.0n', $number);

and enter it back in to the form in currency format.

Now when the user resubmits that form I need to trim all the non int char so that I have only 0-9 values since I am storing it as int.

I can't figure out how to do that.

coopster

11:06 pm on Mar 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



How about preg_replace() [php.net]?
$int = preg_replace("/[^0-9]/", '', $_POST['currency_value'])