Skip to content

Instantly share code, notes, and snippets.

@hayatravis
Created November 27, 2013 03:45
Show Gist options
  • Save hayatravis/7670392 to your computer and use it in GitHub Desktop.
Save hayatravis/7670392 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で日本語をエンコードさせない関数。
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