The values that are between 1, 2, 3, 4
me show decimals as results 0.2
as well as the values 11, 12, 13, 14
show me decimals as results 2.2
and so on.
The rounding works correctly, for example if I have values of 5
it shows me as a result 1
and if I have values of 10
it shows me a result of 2
.
What I want is to eliminate the decimals, not to show it, because the rounding already exists in my variable, any value that is between 5, 10, 15, 20, 25, 30
shows me results without decimals, but if they are values like 1, 2, 3, 4 7, 6, 8, 9, 11, 12, 13, 14, 16, 17, 18, 19
etc, it shows me values with decimals.
In short, I only want to display the rounded values and not the decimals.
What condition should I pass to my variable that brings me the values:
echo $total;
Is there a tool like number_format();
or another that allows me to eliminate the decimals and only allow the rounded ones.
There are several options:
round($var);
precision roundingfloor($var);
round downceil($var);
round upif the results are not as expected see Why can't my programs do arithmetic calculations correctly?
What you need is the function
floor()