public function keyWord($condition) {
$momon = Model()->table('goods')->limit(false)->field('goods_name')->select();
if(is_array($condition) && !empty($condition['goods_name|goods_jingle']) && !empty($momon)) {
$key = $condition['goods_name|goods_jingle'][1];
$key = substr($key,1);
$key = substr($key,0,-1);
$key = $this->removePlace($key);
$str = $this->tolower($key);
foreach($momon as $k=>$v) {
$data_lower = $this->tolower($v['goods_name']);
$v = $this->removePlace($data_lower);
$result = strpos($v, $str);
if($result !== false) {
$father_str_lower = $data_lower;
$father_str = $v;
$chil_str = $str;
break;
}
}
if(!empty($chil_str)) {
$check_arr = explode(' ',$father_str_lower);
foreach($check_arr as $v) {
$chil_str = preg_replace("/".$v."/", " ".$v." ", $chil_str);
$chil_str = preg_replace('/s{2,}/',' ',$chil_str);
$chil_str = trim($chil_str);
}
$_SESSION['chil_str'] = $chil_str;
$condition['goods_name|goods_jingle'][1] = "%".$chil_str."%";
}
}
return $condition;
}
public function tolower($a) {
$b = str_split($a, 1);
$r = '';
foreach($b as $v){
$v = ord($v);
if($v >= 65 && $v<= 90){
$v += 32;
}
$r .= chr($v);
}
return $r;
}
public function removePlace($str) {
$str = preg_replace("/s/is", "",$str);
return $str;
}
public function allLowner_goodsName() {
$data = Model()->table('goods')->limit(false)->select();
return $data;
}