function multi_array_search($array, $search)
{
$result = array();
foreach ($array as $key => $value) {
foreach ($search as $k => $v) {
if (!isset($value[$k]) || $value[$k] != $v) {
continue 2;
}
}
$result[] = $value;
}
return $result;
}
How to use?
Exp;
$array_result = array(array("id"=>1,"name"=>"Ayam"),array("id"=>1,"name"=>"Itik"));
multi_array_search($array_result, ["id" => 1]);
Result :
array("id"=>1,"name"=>"Ayam")
No comments:
Post a Comment