I am trying to build a customized filter function using array_filter() in php
$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;
});
}
The compiler says that the $garde in line($record['grade'] == $grade) is not declared.
What can I do for it?