/** * 截取中文字符串 * @param $content 需要处理的内容 * @param $lengh 长度 * @return $text 返回的内容 */ public static function subText($content, $lengh = 100){ $content = htmlspecialchars_decode($content); $text = str_replace([" "],'',$content); $text = str_replace(["<br>","<br/>"],'\n',$text); $text = strip_tags($text); if(mb_strlen($text) > $lengh){ $text = mb_substr($text,0,$lengh,'utf-8'); $text .='......'; } $text = str_replace(['\n'],'',$text); return $text; }
php截取中文字符串
最新推荐文章于 2023-06-20 17:30:45 发布