作者 jinglong
1 个管道 的构建 通过 耗费 1 秒

修改数组关键字出现次数排序

... ... @@ -342,15 +342,20 @@ class Common
$value['is_new_tag'] = 0;//不用显示新人价标签(新人价标签商品不会出来)
}
$value['image'] = self::absolutionUrlOne($value['image']);
$value['tag'] = explode('|',$value['tag']);
$value['style'] = explode('|',$value['style']);
$value['str_count'] = 0;
if(strpos($value['name'],$keyword) !== false){
//包含
$value['name'] = str_replace($keyword,'<a href="javascript:void(0);" style="color:red;">'.$keyword.'</a>',$value['name']);
$value['str_count'] = substr_count($value['name'],$keyword);
}
$value['image'] = self::absolutionUrlOne($value['image']);
$value['tag'] = explode('|',$value['tag']);
$value['style'] = explode('|',$value['style']);
unset($value['is_new']);
}
$str_count = array_column($res,'str_count');
array_multisort($str_count,SORT_DESC,$res);
$arr['data'] = $res;
//总页数
$arr['total_page'] = Common::countSoft('goods',$where);
... ...