[SOLVED] Strip_html

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Strip_html

Post by Shendemiar »

If i want to convert all strings special characters to html-entites, but leave all the tags intact, what do i need to do?

Like:
aaa<b>ccÄdd</b>aa

would become:
aaa<b>cc&AUML;dd</b>aa
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

[php_man]htmlentities[/php_man]() with a [php_man]str_replace[/php_man]() or two to "fix" the <> marks.

can also be done with a regular expression: [php_man]preg_replace[/php_man]() ... however, it may be more a pain to set up than it's worth.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

[php_man]htmlentities[/php_man]


edit - beaten to it by feyd.... errrrrr
Last edited by John Cartwright on Sun Oct 10, 2004 7:32 pm, edited 1 time in total.
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

Post by Shendemiar »

feyd wrote:[php_man]htmlentities[/php_man]() with a [php_man]str_replace[/php_man]() or two to "fix" the <> marks.

can also be done with a regular expression: [php_man]preg_replace[/php_man]() ... however, it may be more a pain to set up than it's worth.
Thanks, i made a function to do some str_replace to undo "<" ">" "/" loss...
Post Reply