mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Replace numeric entities in userland function (spotted by Goba)
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@190478 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
4d10b07691
commit
08443590ff
1 changed files with 5 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<!-- splitted from ./en/functions/strings.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.html-entity-decode">
|
||||
<refnamediv>
|
||||
|
@ -78,6 +78,10 @@ echo $b; // I'll "walk" the <b>dog</b> now
|
|||
// For users prior to PHP 4.3.0 you may do this:
|
||||
function unhtmlentities($string)
|
||||
{
|
||||
// replace numeric entities
|
||||
$string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
|
||||
$string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
|
||||
// replace literal entities
|
||||
$trans_tbl = get_html_translation_table(HTML_ENTITIES);
|
||||
$trans_tbl = array_flip($trans_tbl);
|
||||
return strtr($string, $trans_tbl);
|
||||
|
|
Loading…
Reference in a new issue