简体   繁体   中英

Removing specific html characters from a string

Its a bit tricky situation. I have a form for users to input their comments. Sometimes, users put in HTML characters. My problem is, I just want to save specific HTML characters like bold, table, tr, td with <> tags. Except this any other HTML characters should be removed from the string. I would like to know how to do this??

strip_tags allows you set list of allowable tags.

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

echo strip_tags($text, '<b><table><tr><td>');

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