Maison >développement back-end >tutoriel php >解决 json_encode 中文乱码_PHP教程
解决以下问题
01
//http://blog.1dnet.net
02
function
_encode(
$arr
)
03
{
04
$na
=
array
();
05
foreach
(
$arr
as
$k
=>
$value
) {
06
$na
[_urlencode(
$k
)] = _urlencode (
$value
);
07
}
08
return
addcslashes
(urldecode(json_encode(
$na
)),
"\r\n"
);
09
}
10
11
function
_urlencode(
$elem
)
12
{
13
if
(
is_array
(
$elem
)){
14
foreach
(
$elem
as
$k
=>
$v
){
15
$na
[_urlencode(
$k
)] = _urlencode(
$v
);
16
}
17
return
$na
;
18
}
19
return
urlencode(
$elem
);
20
}