The preg_grep function is used to return array entries that match a pattern.
array preg_grep ( string $pattern , array $input [, int $flags = 0 ] )
Returns an array consisting of the elements in the given array input that match pattern.
Parameter description:
$pattern: The pattern to be searched, in string form.
$input: input array.
$flags: If set to PREG_GREP_INVERT, this function returns an array of elements in the input array that do not match the given pattern pattern.
The execution result is as follows:
Array( [2] => 3.4 [4] => 7.9)
It can be seen that preg_grep only returns the floating point numbers in the array.