note 78128 deleted from function.html-entity-decode by danbrown

From: Date: Tue, 10 Jan 2012 20:12:32 +0000
Subject: note 78128 deleted from function.html-entity-decode by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185532@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 (#185532) next »