-
-
Save tassoevan/c8a9fc9b61b5446e41d1 to your computer and use it in GitHub Desktop.
json_encode($array,JSON_UNESCAPED_UNICODE) For PHP5.3.
Except json encoding japanese For php5.3.
php5.3のjson_encodeで日本語をエンコードさせない関数。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function json_encode_jp($array) { | |
return preg_replace_callback( | |
'/\\\\u([0-9a-zA-Z]{4})/', | |
function ($matches) { | |
return mb_convert_encoding(pack('H*',$matches[1]),'UTF-8','UTF-16'); | |
}, | |
json_encode($array) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment