hideCate($all_list); //获取券商品的所有分类id $category_ids = goodCouponModel::getCategoryIds(); $category_list = []; if(!empty($all_list) && !empty($category_ids)){ foreach ($all_list as $val){ //筛选出券商品的分类 if(in_array($val["category_id"],$category_ids)){ $category_list[] = $val; } } } return $this->renderSuccess('', compact('category_list')); } public function hideCate($all){ if(empty($all)){ return $all; } foreach ($all as $i=>$first) { if (intval($all[$i]["status"]) === 0){ unset($all[$i]); } if(!empty($all[$i]['child'])){ foreach ($all[$i]['child'] as $j=>$two) { if (intval($all[$i]['child'][$j]["status"]) === 0){ unset($all[$i]['child'][$j]); } if(!empty($all[$i]['child'][$j]['child'])){ foreach ($all[$i]['child'][$j]['child'] as $k=>$three){ if (intval($all[$i]['child'][$j]["child"][$k]["status"]) === 0){ unset($all[$i]['child'][$j]["child"][$k]); } } } } } } return array_values($all); } }