note 80625 deleted from function.htmlentities by danbrown

From: Date: Sun, 17 May 2009 16:51:44 +0000
Subject: note 80625 deleted from function.htmlentities by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154901@lists.php.net to get a copy of this message
Note Submitter: rafael at phpit dot com dot br ---- Looking forward to make an htmlentities that substitutes everything but tags, I've made a solution that goes against "olito24 at gmx dot de" proposed snippet... Here it goes! <?php function htmlButTags($str) { // Take all the html entities $caracteres = get_html_translation_table(HTML_ENTITIES); // Find out the "tags" entities $remover = get_html_translation_table(HTML_SPECIALCHARS); // Spit out the tags entities from the original table $caracteres = array_diff($caracteres, $remover); // Translate the string.... $str = strtr($str, $caracteres); // And that's it! return $str; } ?> Any improvement will be much appreciated! :)

« previous php.notes (#154901) next »