…now every number with 2 decimal points should fit this condition and perform the given action however numbers 1.09-1.15 (2dp) do not unexplicably… so that has led me to the ‘is_int’ function but…
$ex = (1.05*100);
if(is_int($ex)) {
echo "yes it is";
} else {
echo "no you don't!";
}
… as you can see this doesn’t work when a string is a calculation so I’m a little stuck on this and therefore call upon the good people of this forum <<
… perhaps the first piece of code demonstrates what I want to do the best > I want to find the lowest number ($d) that $num*$d is an integer with $num being to 2 decimal points, i.e. any number to 2dp multiplied by a number upto 100 will become an integer.
… in the 2nd piece of code I’m performing the calculation 1.05*100 which is of course equal to 105 which is an integer - but possibly for some reason it remains 105.00 and that’s why is_int doesn’t work for me with this…
After you multiply a float by 100, even though it’s a “whole number”, within the PHP world, it remains a float. I see what you want to do now. I think the issue might be to do with floating point precision (a horrible issue - read about in the Types page I linked to). Try this:
If it has a decimal point, it’s not an integer, it’s a floating point number (“float”). Checking if a string is an integer is always going to fail, because they are different types. If you want to see if a string is a “number”, use the is_numeric function.
Thanks for the replies Raffles >> for some reason it was still missing 1.13 and 1.14 but it seems to be working for all of them (yet to be 100%) with this: