note 90111 added to function.htmlentities

From: Date: Tue, 07 Apr 2009 08:49:51 +0000
Subject: note 90111 added to function.htmlentities
Groups: php.notes 
Request: Send a blank email to php-notes+get-152880@lists.php.net to get a copy of this message
I took one of the previous functions above - (which only encodes the string once - which is great) and added the ability to encode & -> & See below. Its a shame we cant do this straight with htmlentities (with double encode set to false) 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! // oo now amps $str = preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , $str); return $str; } ---- Server IP: 92.48.74.199 Probable Submitter: 87.194.166.44 ---- Manual Page -- http://www.php.net/manual/en/function.htmlentities.php Edit -- https://master.php.net/note/edit/90111 Del: integrated -- https://master.php.net/note/delete/90111/integrated Del: useless -- https://master.php.net/note/delete/90111/useless Del: bad code -- https://master.php.net/note/delete/90111/bad+code Del: spam -- https://master.php.net/note/delete/90111/spam Del: non-english -- https://master.php.net/note/delete/90111/non-english Del: in docs -- https://master.php.net/note/delete/90111/in+docs Del: other reasons-- https://master.php.net/note/delete/90111 Reject -- https://master.php.net/note/reject/90111 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#152880) next »