我想從我的字符串中刪除所有的標籤,並顯示給用戶 我的字符串是:從我的字符串刪除特殊字符標記
$abc='<ol><li>nice products </li></ol>';
echo html_entity_decode($abc);
echo htmlspecialchars_decode($abc);
但它不去除這些tag.can任何一個建議我應該使用什麼。
我目前使用PHP 5.6版
我想從我的字符串中刪除所有的標籤,並顯示給用戶 我的字符串是:從我的字符串刪除特殊字符標記
$abc='<ol><li>nice products </li></ol>';
echo html_entity_decode($abc);
echo htmlspecialchars_decode($abc);
但它不去除這些tag.can任何一個建議我應該使用什麼。
我目前使用PHP 5.6版
,如果你想刪除所有的HTML標籤使用strip_tags()
功能:
$abc = '<ol><li>nice products </li></ol>';
echo strip_tags($abc);
因此@phenix可以發佈這個答案。 –
不,它沒有工作 –
[在線檢查](https://3v4l.org/CvdDq) –
用strip_tags()應該解決您的問題。
它正在http://sandbox.onlinephpfunctions.com/。像你說的PHP 5.6 環境。 複製你的字符串
$abc='<ol><li>nice products </li></ol>';
echo strip_tags($abc);
結果是:美觀大方的產品
也許你可以使用用strip_tags:http://php.net/manual/de/function.strip-tags.php – sengbatz
嘗試:'用strip_tags( $ abc);' –