0

对不起,为什么这不能工作:

function filter($var) {
    return($var['id'] < 4);
}

$t1 = array(
array("key"=>"date", "value"=>"effe", "id"=>2),
array("key"=>"date2", "value"=>"jieffe", "id"=>3),
array("key"=>"date3", "value"=>"efjife", "id"=>4),
array("key"=>"date4", "value"=>"effijoe", "id"=>5),

);

array_filter($t1, "filter");

var_dump($t1);

在http://writecodeonline.com/php/上测试

4

1 回答 1

3

array_filter()返回过滤后的数组,它不是通过引用传递:

$t1 = array_filter($t1, "filter");

var_dump($t1);// done
于 2012-06-27T10:14:17.857 回答