is it possible if callback in array_filter receive parameter?

前端 未结 5 1062
小蘑菇
小蘑菇 2020-12-17 16:05

I got this multiple array named $files[], which consists of keys and values as below :

[0] => Array
(
    [name] => index1.php
    [path]          


        
5条回答
  •  我在风中等你
    2020-12-17 16:16

    You can use create_function() in 5.2.x

    $y = 5;
    $func = 'return $x > ' . $y . ';';
    $f = create_function('$x', $func);
    $numbers = range(0, 10);
    $result = array_filter($numbers, $f);
    print_r($result);
    

    which outputs

    Array ( [6] => 6 [7] => 7 [8] => 8 [9] => 9 [10] => 10 )

提交回复
热议问题