|
Posted by Alvaro G. Vicario on 08/11/06 20:44
*** larry escribió/wrote (Fri, 11 Aug 2006 08:25:39 +0200):
> I'd like to convert this kind of character :
>
> #48;
>
> into a human readable character :
>
> 0
Two suggestions:
<?
$foo='This tring has some chars like #48;, #120; or #64;';
echo preg_replace('/#(\d+);/e', 'chr($1)', $foo);
function char_from_code($foo){
return chr($foo[1]);
}
echo preg_replace_callback('/#(\d+);/', 'char_from_code', $foo);
?>
Yep, I know you probably didn't mean this ;-)
--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
[Back to original message]
|