首頁  >  文章  >  web前端  >  如何去除html標籤

如何去除html標籤

coldplay.xixi
coldplay.xixi原創
2021-04-26 11:38:445906瀏覽

移除html標籤的方法是使用【strip_tags()】函數可以輕鬆實現從字串中移除HTML和PHP標記,語法為【trip_tags ( string $str [, string $allowable_tags ] )】。

如何去除html標籤

本教學操作環境:windows7系統、html5版,DELL G3電腦。

移除html標籤的方法:

foreach ($list['company_list'] as $key => $value) {
$list['company_list'][$key]['summary'] =strip_tags($list['company_list'][$key]['summary']);//去除html标签
$list['company_list'][$key]['summary'] = str_replace(' ',' ', $list['company_list'][$key]['summary']);

 

單字解說:

 

#strip_tags()函數可以輕鬆實作從字串中移除HTML 和PHP 標記。

 

使用方法:

 

trip_tags ( string $str [, string $allowable_tags ] );

 

第一個參數為必須的,也就是要移除HTML 和PHP標記的來源數據,第二個參數是可選的,表示不需要過濾的標記。

 

str_replace()函數使用一個字串取代字串中的另一個字元

語法

str_replace(find,replace,string,count)

如何去除html標籤

相關學習推薦:#html影片教學

以上是如何去除html標籤的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn