Created
April 11, 2016 03:02
-
-
Save taichunmin/5464d5fbb60bd4d39d6db5d2ab5b98cd to your computer and use it in GitHub Desktop.
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
<?php | |
if(!function_exists('encode_json')) { | |
function encode_json( $var ) { | |
static $options = null; | |
if (is_null($options)) { | |
$options = 0; | |
if (version_compare(PHP_VERSION, '5.3.3') >= 0) | |
$options |= JSON_NUMERIC_CHECK; | |
if (version_compare(PHP_VERSION, '5.4.0') >= 0) | |
$options |= JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE; | |
} | |
return json_encode($var, $options); | |
} | |
} | |
$response = [ | |
[ | |
'0' => '不分區', | |
'north' => '北', | |
'east' => '東', | |
'west' => '西', | |
'middle' => '中', | |
'south' => '南', | |
], | |
]; | |
echo encode_json($response).PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment