关于这个问题有很多帖子,但没有一个帮助我解决这个问题。
$array=array(
"dépendre"=>"to depend",
"dire"=>"to say",
"distraire"=>"distracted",
"être"=>"to be (being)",
);
使用 json_encode
像这样编码:
"d\u00e9pendre":"to depend","dire":"to say","distraire":"distracted","\u00eatre":"to be (being)"
到目前为止我已经试过了:
array_walk_recursive($array,function($value,$key) {
$key = urlencode(utf8_decode($key));
});
最佳答案
试试这个,
json_encode($array, JSON_UNESCAPED_UNICODE);
你应该得到这个结果;
{
"dépendre":"to depend",
"dire":"to say",
"distraire":"distracted",
"être":"to be (being)"
}
关于php - 如何对带有法语口音的数组进行 JSON 编码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47157718/