3v4l.org

run code in 300+ PHP versions simultaneously
<?php $json = array( "Sample" => array( "context" => 'جمهوری اسلامی ایران', "test" => '\u1234', ) ); $encoded = json_encode($json); var_dump($encoded); $unescaped = preg_replace_callback('/(?<!\\\\)\\\\u(\w{4})/', function ($matches) { return html_entity_decode('&#x' . $matches[1] . ';', ENT_COMPAT, 'UTF-8'); }, $encoded); var_dump($unescaped);

preferences:
23.34 ms | 407 KiB | 5 Q