I need to validate inputs - find out, if inputs are float. According to websites, my code should work, but it doesnt.
<?php
$new_estimate=array("3.3","10.3","1.1","2.35");
$mistake="no";
for ($i=0; $i<(sizeof($new_estimate)); $i++)
{
if (!is_float($new_estimate[$i]))
{
$mistake="yes";
}
}
echo $mistake;
?>
I think all values of array are float, but browser shows "yes" - instead my expectation. I dont understand, why it doesnt work.
$new_estimate=array(3.3,10.3,1.1,2.35);Avar_dump()would show you this.FILTER_VALIDATE_FLOATperhaps, when the sample array is meant to be form input?float, it's bound to be afloatso testing for that will not do much...