在PHP中从json获取utf8

时间:2015-03-24 03:57:32

标签: php

我有一个JSON:

$json = "{"guid": 1, "cid": 644, "lastest": [{"stt": 1, "uid": 111, "created": 1427168366, "update": 780, "content": "qu\\xc3\\xaa t\\xc3\\xb4i", "cname": "mvd", "parentid": 0, "highlight": 0}]}"

$arr =json_decode($json, true)
echo $arr['lastest'][0]['content'].

显示qu\\xc3\\xaa t\\xc3\\xb4i.

但我想展示"quê tôi".

在标题处,我设置:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

怎么办?非常感谢!

1 个答案:

答案 0 :(得分:1)

我在本地主机上尝试了以下,我得到了你的解决方案

<?php 
header('Content-Type: text/html; charset=utf-8');
echo "qu\xc3\xaa t\xc3\xb4i";

//I removed backshlash qu\\xc3\\xaa t\\xc3\\xb4i -> qu\xc3\xaa t\xc3\xb4i
?>

但是json仍然存在问题 可能是Bassem Lhm对编码是正确的

相关问题