Passing decoded Cyrillic Characters in json_encode

To decode the encoded cyrillic characters like \u041D in an array and to pass it to json_encode, follow the below technique

json_encode($array, JSON_UNESCAPED_UNICODE);


$json = defined('JSON_UNESCAPED_UNICODE') ? json_encode($array, JSON_UNESCAPED_UNICODE) : json_encode($str);

or if PHP 5.4 and below

preg_replace_callback('/\\\u([01-9a-fA-F]{4})/', 'prepareUTF8', json_encode($array))

One Reply to “Passing decoded Cyrillic Characters in json_encode”

  1. Your article is really helpful. thnks…

Leave a Reply