Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

character conversion

0 views
Skip to first unread message

larry

unread,
Aug 11, 2006, 2:25:39 AM8/11/06
to
Hello,

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


strawberry

unread,
Aug 11, 2006, 3:03:53 AM8/11/06
to

Where did you look exactly!?!

<?
echo chr(48);
?>

starosta

unread,
Aug 11, 2006, 3:09:45 AM8/11/06
to
larry wrote:

> 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 &#48; 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

Alvaro G. Vicario

unread,
Aug 11, 2006, 4:44:02 PM8/11/06
to
*** 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
--

larry

unread,
Aug 12, 2006, 9:48:48 AM8/12/06
to
"Alvaro G. Vicario" <webm...@NOSPAMdemogracia.com> a écrit dans le message
de news: 1qsioqa49tj44$.1kt5d9ixv11br$.dlg@40tude.net...

thank you all for your answers.

--
larry


0 new messages