我想要json_encode一个php数组,但“选择”部分返回null。json_encode在数组上返回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);
听起来像它不喜欢在文本值。 –
我明白这一点。即时通讯设法弄清楚为什么 – user2570937
你能澄清一下:你是来自'print_r'还是什么的第一行('Array ...')?显示你如何定义该数组。你确定要逃避所有这些引号吗? – philtune