复制代符号代仔例:
function tb_json_encode($value, $options = 0)
{
return json_encode(tb_json_convert_encoding($value, “GBK”, “UTF-8″));
}
function tb_json_decode($str, $assoc = false, $ Depth = 512)
{
return tb_json_convert_encoding(json_decode($str, $assoc), “UTF-8″, “GBK”);
}
function 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_encoding($m, $to, $from);
case ‘オブジェクト’:
$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, $from, $to);
}
$m を返します。
デフォルト:
}
$mを返します。
}
http://www.bkjia.com/PHPjc/321266.htmlwww.bkjia.com本当http://www.bkjia.com/PHPjc/321266.html技術記事代制コード次のように: function tb_json_encode($value, $options = 0) { return json_encode(tb_json_convert_encoding($value, “GBK”, “UTF-8″));関数 tb_json_decode($...