note 91262 deleted from function.htmlentities by danbrown
| From: | danbrown@php.net | Date: | Tue, 02 Jun 2009 18:39:08 +0000 |
| Subject: | note 91262 deleted from function.htmlentities by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-156302@lists.php.net to get a copy of this message | ||
Note Submitter: Thierry Gagnon
----
Here's a simple function to convert the ASCII code to it's character equivalent in a
string (especially useful for french accent):
function ascii_trans($string){
function ascii_switch($matches){
return chr(substr($matches[0], 2, -1));
}
return preg_replace_callback("/&#[0-9][0-9][0-9];|&#[0-9][0-9];/",
"ascii_switch", $string);
}
echo ascii_trans("C’est pas compliqué"); return C'est pas
compliqué