note 55159 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:27:04 +0000
Subject: note 55159 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127611@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 (#127611) next »