note 55158 deleted from function.htmlentities by danbrown

From: Date: Sun, 17 May 2009 17:02:02 +0000
Subject: note 55158 deleted from function.htmlentities by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154926@lists.php.net to get a copy of this message
Note Submitter: webmaster at swirldrop dot com ---- To replace any characters in a string that could be 'dangerous' to put in an HTML/XML file with their numeric entities (e.g. &#233 for é [e acute]), you can use the following function: function htmlnumericentities($str){ return preg_replace('/[^!-%\x27-;=?-~ ]/e', '"&#".ord("$0").chr(59)', $str); };//EoFn htmlnumericentities To change any normal entities (e.g. €) to numerical entities call: $str = htmlnumericalentities(html_entity_decode($str));

« previous php.notes (#154926) next »