For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > November 2004 > Problem with htmlentities and tags









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem with htmlentities and tags
Andreas Frey

2004-11-30, 8:56 pm

Hi all,

is there an easy way to take a html-document and use a function like
htmlentities without changing html-tags.

Thanks for your help.

Greetings Andy
Andreas Frey

2004-11-30, 8:56 pm

> <?php
> $table = get_html_translation_table(HTML_ENTITIES
)
> unset($table['<']);
> unset($table['>']);
> unset($table['"']);
> $text = str_replace(array_keys($table), array_values($table), $text)
> ?>
>
> Of course, if you want to convert < > and " as well, but leave out tags,
> it does get more difficult. I'm sure there are some regex gurus who can
> tell you more about that.

Thats exactly what i want ...
But thanks nevertheless
Andy
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com