複製程式碼程式碼如下: function tb_json_encode($value, $options = 0) { {} function tb_json_decode($str, $assoc = false, $depth = 512) { return tb_json_convert_encoding(json_decode($str, $assoc), “UTF-vassoc. 」); } 函數tb_json_convert_encoding($m, $from, $to) { switch(gettype($m)) { case 'integer': case 'boolean' : case 'float': case 'double': case 'NULL': return $m; case 'string': return mb_convert_encomb_convert_encof m, $to, $from); case 'object': $vars = array_keys(get_object_vars($m)); foreach($vars as $key) { $m- >$key = tb_json_convert_encoding($m->$key, $from ,$to); 回傳$m; case 'array': foreach($m as $k = > $v) { $m[tb_json_convert_encoding($k, $from, $to)] = tb_json_convert_encoding($v, $從,$到); } 返回$m; 默認值:} 回傳$m; } 以上就介紹了js格式化GBK的頁面輸出JSON格式的php函數,包含了js格式化方面的內容,希望對PHP教學有興趣的朋友有幫助。