$arr = array(
array(
"catid" => 2,
"catdir" => "notice",
),
array(
"catid" => 5,
"catdir" => "subject",
),
array(
"catid" => 6,
"catdir" => "news"
),
);
$catid = 5;
$res = array_filter($arr, function($param) use ($catid) {
return $param["catid"] == $catid;
});
print_r($res);
my current code outputs the following secondary array
array(1) {
[1]=>
array(2) {
["catid"]=>
int(5)
["catdir"]=>
string(7) "subject"
}
}
I want to output the following format
array(2) {
["catid"]=>
int(5)
["catdir"]=>
string(7) "subject"
}
in addition, I don"t quite understand closure functions, and there are the following questions: what are the variables
1, $param and $catid used
2, and what is use used here