2

我有这样的数组

Array
(
    [0] => Array
        (
            [image] => http://domain/photogal/tues/image/2012octo30big11.jpg
            [news] => 'ssN ^mj³ ho¡n dm¼nse¯nb tamUÂ<br>
    '
        )
)

我将此数组编码为json并得到这样的结果

   [{"image":"http:\/\/domain\/photogal\/tues\/image\/2012octo30big11.jpg",
"news":"'ssN ^mj"}]

几乎所有新闻都不在 json 字符串中。json 如何编码到这个数组?

4

1 回答 1

1

您可以尝试将 UTF-8 标头放在任何其他 PHP 代码之前吗?

header('Content-Type: text/html; charset=utf-8');

在我的测试中,您的数组已转换为:

    {"image":"http:\/\/domain\/photogal\/tues\/image\/2012octo30big11.jpg",
"news":"'ssN ^mj\u00b3 ho\u00a1n\u00c2 dm\u00bcnse\u00afnb tamU\u00c2
    \r\n\t'"}

之后使用 json_decode 恢复到原始状态而不会丢失任何符号..

于 2012-10-30T05:28:40.833 回答