Page 1 of 1

Removing Decimal Point

Posted: Thu Oct 23, 2008 5:42 am
by JimmyNo
Hi

I am new to PHP and I have a form where the person has to manually enter the price for a item. For some reason my payment processor wont accept decimal points!! Example if a item is 1200 or 1200.00 and that is submitted then it appears as 12.00 at the processors end. To have the value 1200.00 appear on my payment processor someone would have to type 120000!

Also if someone types in 1200 is there a way I can have two extra 0's added?

Re: Removing Decimal Point

Posted: Thu Oct 23, 2008 6:19 am
by papa

Re: Removing Decimal Point

Posted: Thu Oct 23, 2008 8:36 am
by JimmyNo
Unfortunately thats no good as I need to remove the decimal point.

Re: Removing Decimal Point

Posted: Thu Oct 23, 2008 8:45 am
by onion2k
JimmyNo wrote:Also if someone types in 1200 is there a way I can have two extra 0's added?
Multiply the number by 100?

Re: Removing Decimal Point

Posted: Thu Oct 23, 2008 8:53 am
by VladSun
Maybe if we had a look at your "payment processor" coude we would be more helpful ;)

Re: Removing Decimal Point

Posted: Thu Oct 23, 2008 8:54 am
by aceconcepts

Code: Select all

number_format()

Re: Removing Decimal Point

Posted: Thu Oct 23, 2008 8:56 am
by JimmyNo

Code: Select all

$new_string = preg_replace("/[^a-zA-Z0-9s]/", "", $string);
FYI: The above removed the decimal point!
Multiply the number by 100?
Er...... Bloody hell yes! That would sort out my problem including the decimal point! Cheers Mate! I couldn't see the forest through the trees! The simple solutions wins the prize!