我想搜索 Mobile 或 mobile legend 或 mobile。它应该返回两个数组。但是我的代码只有在我搜索完全相同的词时才有效。请帮忙。
$resutls = [];
$words = ['mobile', 'Mobile Legend', 'Mobile', 'mobile legend'];
foreach ($items as $item) {
if(in_array($item['CategoryName'], $words)) {
$results[] = $item;
}
}
print_r($results);
[0] => Array
(
[id] => 1
[Name] => Mobile Game,
[CategoryName] => Mobile Legend
)
[1] => Array
(
[id] => 2
[Name] => Laptop Game
[CategoryName] => Mobile
)
潇潇雨雨