CalcBuilder Forum

How can I make calcbuilder ignore commas

User moon_584 2012-07-31 21:51:56

My calculators have been working great but I just noticed one major flaw. If the user types in a comma in the number (for example 1,000,000), it's recognizing that number as zero. How can I fix that?

Moonsoft support 2012-07-31 22:47:46

Yes, you should get rid of them before executing operations, because numbers with commas are not valid numbers and that's why they are handled as 0 . Before going to the operations, parse user input this way at the beginning of your code:

$input1=str_replace(",","",$input1);


This will clean the $input1 number from the comma sign and can be used as a number afterwards.

Hope this helps,

...
Support/development 40 hours

With the peace of mind of having a professional team at your service (20% discount)

Buy now!
...
CalcBuilder

Create dynamic calculators

Buy now!