Search code examples
phpfileunicodeunicode-string

Replace unicode characters in filename?


I am using an upload form which returns uploaded files on the following form:

["http://domain.com/wp-content/uploads/gravity_forms/120-311e1865ce18d60a3e14cd555669bfa5/2016/11/Sk\u00e6rmbillede-2016-11-27-kl.-10.17.0431.png","http://domain.com/wp-content/uploads/gravity_forms/120-311e1865ce18d60a3e14cd555669bfa5/2016/11/Sk\u00e6rmbillede-2016-11-27-kl.-15.46.5425.png"]

I would like to remove all brackets, backslashes and quotes, which I am successfully doing with str_replace. However, '\u00e6' is unicode for the special character 'æ'.

How can I replace all unicode characters like that with their corresponding special chars?


Solution

  • That is a JSON encoded array.

    Use the json_decode function to convert it to a PHP array. The Unicode escapes will be dealt with as well.