i am trying to match exact number with decimal. i have tried following but doesn't work
tried following code, but doesn't work with decimal.
<?php
$number=1.23;
$numbers=1.28;
if (is_float($number)==is_float($numbers))
{
echo 'matched';
}else{
echo 'not matched';
}
?>
please check where i am doing mistake or it's totally wrong way to do that. i have check above in PHP sites.
Use floatval
(which returns the float value of the given variable) instead of is_float
(which returns true
if the given variable is a float and false
if it isn’t).
You could simply make use of a strict matching operator ===
instead of floatval
or is_float
.
<?php
$number=1.23;
$numbers=1.28;
if($number === $numbers)
{
echo "Matched";
}
else { echo "No Match"; }