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

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

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