我想要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