I have two forms, where user must enter number
First form - number (for example - 100)
Second form - percent. User must enter number without percent sign (for example- 10)
Then i do calculations.
First number multiply by percent (100*10/100)
But if user will enter not 10, but 10% , then calculation will be 100*10%/100
So i need to convert possible 10% to 10
may be it is simple solution, but my programming knowledge is very poor.....
hmmm, it seem it automaticaly is number? If I enter number with % sign, in calculation is used only number without percent sign?
Is it true?
number with % (percent) sign change to number
Moderator: General Moderators
Re: number with % (percent) sign change to number
PHP will automatically convert string into number when used with math operators. You can make sure by casting it into an integer -
Code: Select all
$number = (int) $number;Re: number with % (percent) sign change to number
Thanks a lot.