/**
* 获取富文本字符串的纯文本,截取
* @param $string
* @param int $number
* @return string|null
*/
function StringToText($string,$number = 120): string
{
if($string){
$html_string = htmlspecialchars_decode($string);
$content = str_replace([" ","\t","\n","\r"], "", $html_string);
$contents = strip_tags($content);
return mb_strlen($contents,'utf-8') > $number ? mb_substr($contents, 0, $number, "utf-8").'...' : mb_substr($contents, 0, $number, "utf-8");
}else{
return $string;
}
}