1,php截取富文本的內容只顯示一部分,去除其他所有的標簽
$content = $data["content"]; #從數據庫獲取富文本content $content = htmlspecialchars_decode($content); #把一些預定義的 HTML 實體轉換為字符 $content = str_replace(" ","",$content); #將空格替換成空 $content = strip_tags($content); # 函數剝去字符串中的 HTML、XML 以及 PHP 的標簽,獲取純文本內容 $con = mb_substr($content, 0, 100,"utf-8"); #返回字符串中的前100字符串長度的字符 var_dump($con); #打印輸出
原文鏈接:https://blog.csdn.net/ouxiaoxian/article/details/79558157
附 另一個講解的博客:https://www.cnblogs.com/North-South/p/9021022.html
