Re: html_entity_decode () for …, ’, etc.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marco

To awnser you question I do not know why it is excluded from the default 
decode array. Maybe it could be that these are multibyte characters (any 
takers)?

You can get a list of the entities that are changed

$trans = get_html_translation_table(HTML_ENTITIES);
echo"<pre>";print_r($trans);echo"</pre>";

to add some extras as you have below, use something similar to

function htmldecode($string)
{
        $trans = get_html_translation_table(HTML_ENTITIES);
        $trans[chr(0xe2).chr(0x80).chr(0xa6)] = '&hellip;';
        $trans = array_flip($trans);
        return strtr($string, $trans);
}

$string = "&hellip;&amp;";
echo htmldecode($string) ."\n";

Note: obviously hex e2 80 a6 make up the hellip chars.

Hope this helps

Cheers

--
Leon

On Wednesday 10 August 2005 20:55, Marco wrote:
> I tried using html_entity_decode () but why won't these characters decode:
>
> &rsquo;
> &ndash;
> &hellip;
> &ldquo;
> &rdquo;

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux