Remove e modifier from this preg_replace mod

Hi,

so i’ve found a really useful function to convert accented characters to utf8 http://www.avoid.org/replace-u-characters-in-json-string/ and i am pretty sure it uses the e-modifier which is now depreciated.

I’ve changed it slightly for my purposes as i don’t need it to output json but i don’t know how to rewrite it to remove the e-modifier (assuming i am correct in thinking that is what the ‘e’ is doing in there).

function jsonRemoveUnicodeSequences($struct) { return preg_replace("/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", $struct); }
I’m not very good with preg_replace so forgive if this is very simple.

any help appreciated

thanks

you need to use preg_replace_callback() to get rid of the modifier.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.