How to get only the float numbers from array in PHP

1 Answer

0 votes
$arr = array(17, "89", 3.14, 78, "PHP", null, 98.1, true, 100, false); 

foreach ($arr as $val) {
    if (is_float($val))
        echo $val . "\n";
}



/*
run:

3.14
98.1

*/

 



answered Dec 5, 2022 by avibootz

Related questions

1 answer 103 views
1 answer 206 views
1 answer 207 views
1 answer 167 views
1 answer 107 views
...