简体   繁体   中英

php strip_tags issue

i want to strip all the html tags from a string except ( <img> and <br> ).

i used strip_tags(); but it stript all the html tags.

regards

那些需要在第二个参数中指定。

echo strip_tags($text, '<img><br>');

The second optional argument of strip_tags is allowable tags

string strip_tags ( string $str [, string $allowable_tags ] )

So you would use the function as strip_tags($str, "<img><br>")

根据文档http://php.net/manual/fr/function.strip-tags.php ,您需要添加第二个参数,一个包含允许标记的字符串。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM