note 104617 modified in function.html-entity-decode by danbrown
| From: | danbrown@php.net | Date: | Sun, 26 Jun 2011 16:01:20 +0000 |
| Subject: | note 104617 modified in function.html-entity-decode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180967@lists.php.net to get a copy of this message | ||
If you need something that converts &#[0-9]+ entities to UTF-8, this is simple and works:
<?php
/* Entity crap. /
$input = "Fovič";
$output = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return
mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $input);
/* Plain UTF-8. */
echo $output;
?>
--was--
If you need something that converts &#[0-9]+ entities to UTF-8, this is simple and works:
/* Entity crap. /
$input = "Fovič";
$output = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return
mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $input);
/* Plain UTF-8. */
echo $output;
http://php.net/manual/en/function.html-entity-decode.php