第三个参数是 指定查询字段参数,如果不用查询就是根据全字段模糊查询
/**
* 二维数组模糊查询
* @Author Xven <270988107@qq.com>
* @param [type] $array [description]
* @param [type] $keyword [description]
* @return [type] [description]
*/
function searchArray($array, $keyword, $find = '') {
return array_filter($array, function ($item) use ($keyword) {
foreach ($item as $value) {
if (!empty($find)) {
if (stripos($value[$find], $keyword) !== false) {
return true;
}
} else {
if (stripos($value, $keyword) !== false) {
return true;
}
}
}
return false;
});
}