把常见的分隔符按照自定义的格式分割
自定义还需在提炼一下
// 格式化关键字 protected function formatting_keyword($txt) { $txt = trim($txt); $arr = [',',',','、',';',':','|',';']; //这里放要过滤的 foreach ($arr as $k=>$v) { if(strpos($txt, $v) !== false){ $zhi = $v; } } if ($zhi){ $txt2 = str_replace($zhi, ";", $txt); //此处是;分割符 $jieguo = preg_replace("/[\s]+/is", "", $txt2); }else{ $jieguo = preg_replace("/[\s]+/is", " ", $txt); $jieguo = str_replace(' ', ";", $jieguo);
//此处是;分割符
} return $jieguo; }