Cloud Strifes Cloud Strifes - 1 month ago 10x
PHP Question

PHP - How convert chracters like "\xea" to correct "ê" character? (ISO-88591 - accented)

I have many characters in a text / json like:

\xea = ê
\xaa = ª (I think)

How convert to correct character in PHP?

Thanks a lot.


You could try something like this:

$text = preg_replace_callback('/\\\\x([0-9a-fA-F]{2})/', function ($matches) { return chr(hexdec($matches[1])); },$text);

Edit: Sorry, I just copy/pasted an old code - the e modifier is deprecated.