note 80625 added to function.htmlentities

From: Date: Fri, 25 Jan 2008 16:27:18 +0000
Subject: note 80625 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-135411@lists.php.net to get a copy of this message
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! :) ---- Server IP: 69.147.83.197 Probable Submitter: 201.86.248.2 ---- Manual Page -- http://www.php.net/manual/en/function.htmlentities.php Edit -- https://master.php.net/note/edit/80625 Del: integrated -- https://master.php.net/note/delete/80625/integrated Del: useless -- https://master.php.net/note/delete/80625/useless Del: bad code -- https://master.php.net/note/delete/80625/bad+code Del: spam -- https://master.php.net/note/delete/80625/spam Del: non-english -- https://master.php.net/note/delete/80625/non-english Del: in docs -- https://master.php.net/note/delete/80625/in+docs Del: other reasons-- https://master.php.net/note/delete/80625 Reject -- https://master.php.net/note/reject/80625 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#135411) next »