I'd like to convert this kind of character :
#48;
into a human readable character :
0
I can't find the function that does this in the doc, so I used
str_replace...
does anyone know ?
thanks in advance,
--
larry
Where did you look exactly!?!
<?
echo chr(48);
?>
> I'd like to convert this kind of character :
>
> #48;
>
> into a human readable character :
>
> 0
>
> I can't find the function that does this in the doc, so I used
> str_replace...
> does anyone know ?
You can convert 0 to 0 with
http://www.php.net/manual/en/function.html-entity-decode.php function
or use preg_replace. Some examples are in user notes of
html_entity_decode function documentation.
--
Tomasz Rup
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
--
thank you all for your answers.
--
larry