Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
json_encode 显示中文
function __json_encode( $obj )
{
if( defined( 'JSON_UNESCAPED_UNICODE' ) ){ // >= php 5.4
return json_encode( $obj, JSON_UNESCAPED_UNICODE );
} else {
return preg_replace( "/\\\\u([a-f0-9]{4})/e", "iconv('UCS-4LE','UTF-8',pack('V', hexdec('U$1')))", json_encode( $obj ) );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.