從php字符串中刪除所有html標(biāo)簽我想顯示數(shù)據(jù)庫條目的前110個字符。到目前為止很容易:<?php echo substr($row_get_Business['business_description'],0,110) . "..."; ?>但是上面的條目中有html代碼,由客戶輸入。所以它顯示:<p class="Body1"><strong><span style="text-decoration: underline;">Ref no:</span></strong> 30001<strong></stro...顯然沒有好處。我只想刪除所有的html代碼,所以我需要從db條目中刪除<和>之間的所有內(nèi)容然后顯示前100個字符。任何人的想法?
3 回答

函數(shù)式編程
TA貢獻(xiàn)1807條經(jīng)驗 獲得超9個贊
使用PHP的strip_tags()函數(shù)。
例如:
$businessDesc = strip_tags($row_get_Business['business_description']);$businessDesc = substr($businessDesc, 0, 110);print($businessDesc);
- 3 回答
- 0 關(guān)注
- 1226 瀏覽
添加回答
舉報
0/150
提交
取消