Convert special characters to ISO Latin-1 code with php

Hi,

How can I convert special characters to ISO Latin-1 code with php?

For instance, I want to convert

á

to

á

but not

á

I have looked around online but still no luck.

Please help if you have any ideas.

Thanks,
Lau

Try this function from php.net


function numeric_entities($string){
    $mapping = array();
    foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity){
        $mapping[$entity] = '&#' . ord($char) . ';';
    }
    return str_replace(array_keys($mapping), $mapping, $string);
}

its perfect! thank you very much.