public function materials(array $categories, array $materials, array $tagsMap, array $tagsFitlerLevel, array $tagsFitlerFood, array $tagsFitlerTreatment) {
$arrayMaterials = [];
$categories = array_flip($categories);
$tagsFitlerLevel = array_flip($tagsFitlerLevel);
$tagsFitlerFood = array_flip($tagsFitlerFood);
$tagsFitlerTreatment = array_flip($tagsFitlerTreatment);
foreach ($materials as $value) {
if (isset($categories[$value->catid])) {
foreach ($tagsMap as $tag) {
if ($tag->content_item_id == $value->id && isset($tagsFitlerLevel[$tag->tag_id]) && isset($tagsFitlerFood[$tag->tag_id]) && isset($tagsFitlerTreatment[$tag->tag_id])) {
$arrayMaterials[] = [
$value->id,
$value->title,
$value->catid
];
break;
}
}
}
}
return $arrayMaterials;
}
а лучше использовать ajax