CalcBuilder Forum

How can I make calcbuilder ignore commas

Usuario 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,

...
List Manager

Build different lists for your site

Buy now!
...
Support/development 10 hours

Get a bigger amount of hours for more complex tasks and get a 10% discount

Buy now!