note 78129 deleted from function.html-entity-decode by nlopess

From: Date: Fri, 28 Sep 2007 23:42:42 +0000
Subject: note 78129 deleted from function.html-entity-decode by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130900@lists.php.net to get a copy of this message
Note Submitter: Fabian ---- Actually I am not sure about the regex replacements from numeric entities back. If you give &#039; to a browser. &#39; will also turn into a single quote. But if I do a: <?php chr(039); ?> I will get not a single quote but a heart character (haven't seen it since DOS days :)) However <?php chr(39); ?> gives the correct result. This makes the correct preg something like this <?php $string = preg_replace('~&#x0*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string); $string = preg_replace('~&#0*([0-9]+);~e', 'chr(\\1)', $string); ?> The reason is also already found on preg_replace manual page: http://de.php.net/manual/en/function.preg-replace.php#69478 039 is interpreted as octal

« previous php.notes (#130900) next »