Use the function to urlencode the chinese character
function JsonObjURLEncodeRecursive(&$jsonobj)
{
if(count($jsonobj) > 0)
{
$potype = gettype($jsonobj);
if(strcmp($potype,"array") == 0)
{
foreach($jsonobj as $okey=>$ovalue)
{
$otype = gettype($ovalue);
if(strcmp($otype,"string") == 0)
{
$jsonobj[$okey] = urlencode($ovalue);
}
else
{
$dealvalue = &$jsonobj[$okey];
JsonObjURLEncodeRecursive($dealvalue);
}
}
}
}
}
usage:
JsonObjURLEncodeRecursive($jsonobj);
$str = urldecode(json_encode($jsonobj));
echo $str;
PHP 处理json中的中文
最新推荐文章于 2021-03-19 20:36:18 发布