1
I’m taking a value from a form that comes like this:
1222,22 (no point in the thousand, only with the
,decimally)
So I’m creating a condition, like this:
if ($var1 < 1111,11) {
$var2 = 1;
}
elseif ($var1 > 1111,11 && $var1 < 9999,99) {
$var2 = 2;
}
else {
$var2 = 3;
But it’s not working, it seems that the , not accepted there on the condition... I tried also as string (putting the numbers in quotes), and so already accepted, but also not solved.
I think you can use or round(), it has a nice condition... but usually not use
,to decimal. use.....– Sr. André Baill
I’ve tried with the
., but how do I get with,didn’t work out... didn’t understand what you meant by useround(), if what I want is to consider the decimal place... for example, if the value entered is1111,12, then$var2 = 2.– gustavox
But in order to be able to verify, you will have to then format the number coming, you can use number_format(), to update the variable, making it with dot, and then elaborate the comparison.
– Sr. André Baill
@Andrébaill Oh I get it, it worked like this:
if (number_format($var1, 2, ".", "") < 1111.11)etc... Put as answer. Thanks!– gustavox