note 34449 modified in function.htmlentities by danbrown

From: Date: Sun, 17 May 2009 17:10:50 +0000
Subject: note 34449 modified in function.htmlentities by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154951@lists.php.net to get a copy of this message
In case you want a 'htmlentities' function which prevents 'double' encoding of the ampersands of already present entities (> => >), use this: function htmlentities2($myHTML) { $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES); $translation_table[chr(38)] = '&'; return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($myHTML, $translation_table)); } --was-- In case you want a 'htmlentities' function which prevents 'double' encoding of the ampersands of already present entities (> => >), use this: function htmlentities2($myHTML) { $translation_table=get_html_translation_table (HTML_ENTITIES,ENT_QUOTES); $translation_table[chr(38)] = '&'; return preg_replace("/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/","&" , strtr($myHTML, $translation_table)); } http://php.net/manual/en/function.htmlentities.php

« previous php.notes (#154951) next »