【发布时间】:2021-02-25 03:27:38
【问题描述】:
我正在尝试在 php 中使用 array_filter() 构建自定义过滤器功能
$lst = [["indexNo" => '123', "name" =>"aaa", grade => 8],
["indexNo" => '124', "name" =>"abc", grade => 8],
["indexNo" => '125', "name" =>"avb", grade => 9]
];
function filterByIndex($grade){
global $lst;
return array_filter($lst, function($record){
$record['grade'] == $grade;
});
}
编译器说$garde in line($record['grade'] == $grade) 没有声明。
我能为它做些什么?
【问题讨论】:
标签: php multidimensional-array array-filter