我正在尝试json_encode一个php数组,但是“选择”部分返回null。
Array ( [indexer] => 7 [section] => 1 [question] => What does the last paragraph indicate about an optimistic perspective? [answer] => a [choices] => There has never been a culture or religion that is genuinely optimistic`It is “a riddle of the universe”`No enlightened culture sees the world in a truly optimistic manner`Optimistic perspectives are only held by the weak )
{"indexer":"7","section":"1","question":"What does the last paragraph indicate about an optimistic perspective?","answer":"a","choices":null}知道为什么吗?
编辑:完整代码:
$check = mysqli_query($con, "select * from questions where section = '$section' and indexer = '$question'");
$result = mysqli_fetch_array($check, MYSQLI_ASSOC);
print_r($result);
echo json_encode($result);发布于 2014-12-30 22:58:11
编码,编码期望您编码的所有内容都是有效的UTF-8。如果内容的任何部分不是正确的UTF-8,json_encode将为该部分(b )默默地失败。
所有字符串数据必须被UTF-8编码.
我的猜测是,“标记没有正确地编码UTF-8 (而是起源于基于CP1252的编码)。
请参阅错误从json模块检索最后一个错误代码。
https://stackoverflow.com/questions/27713496
复制相似问题