LoginSignup
23
19

More than 5 years have passed since last update.

json_encode()の戻り値をUnicodeエスケープしないようにする

Last updated at Posted at 2012-12-26

第2引数に JSON_UNESCAPED_UNICODE フラグを指定

<?php
var_dump(json_encode(array('ゆどうふ' => 'をぞぞ')));
//string(49) "{"\\u3086\\u3069\\u3046\\u3075":"\\u3092\\u305e\\u305e"}"

var_dump(json_encode(array('ゆどうふ' => 'をぞぞ'), JSON_UNESCAPED_UNICODE));
// string(28) "{"ゆどうふ":"をぞぞ"}"

使えるのはPHP 5.4からですけどね。

23
19
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
23
19