The following code does not capture 45.00 as a result:
$array = array(50,45.00,34,56,6.67);
$fl_array = preg_grep("/^(\d+)?\.(\d)+$/", $array);
Any suggestion?
The following code does not capture 45.00 as a result:
$array = array(50,45.00,34,56,6.67);
$fl_array = preg_grep("/^(\d+)?\.(\d)+$/", $array);
Any suggestion?
Copyright © 2021 Jogjafile Inc.
If you do a
var_dump($array);
you will get:PHP you transform
45.00
into45
. That's why you can't find with the regex.What you can do is to insert only strings.
Then it's going to work.
Another option is to filter only float numbers from the array: