我遇到了顯示帶有json_encode的json的問題。問題是在某個點之後會被截斷。我猜測2500線左右。我已經閱讀了大量的計算器,其他人建議增加內存限制。我已經增加了它已經到32m ,它仍然被截斷此外,我不認爲這是我回應了內存使用情況的問題,並與真正我得到3.5mb和假我得到1.5mb我也嘗試編碼它到1000,但直到某個點它仍然截斷。php json encode large arrays gets truncated
的json看起來像這樣
{ 「ID」: 「1」},{ 「詞」: 「」},{ 「位置」: 「0」},{ 「長度」: 「0」 },{ 「Pdf_Id」: 「1」}
只是2000多
我的代碼是這樣的:
JSON文件
echo json_encode(array_values($db->getallqueryjsoncountStart("words_table","Allwords",4000,0)));
public function getallqueryjsoncountStart($table,$jsonparentname,$count,$start)
{
$this->sqlquery = "select * from $table LIMIT $start,$count";
$this->stmt = $this->conn->query($this->sqlquery);
for ($i = 0; $i < $this->stmt->columnCount(); $i++) {
$col = $this->stmt->getColumnMeta($i);
$columns[] = $col['name'];
}
$this->initcnt = 0;
$getqueryJson = array();
while($this->row = $this->stmt->fetch())
{
for($x = 0;$x < sizeof($columns);$x++)
{
$getqueryJson[][$columns[$x]] = $this->row[$columns[$x]];
}
}
return $getqueryJson;
}
也許值得改變SQL查詢中記錄的順序,以確保json_encode在2500行後仍然中斷,而不是因爲要編碼的數據有問題。 – 2014-11-02 13:19:10
'json_last_error()'的輸出是什麼? http://php.net/manual/en/function.json-last-error.php – robbmj 2014-11-02 13:22:10
改變了順序仍然約2500線斷裂。 json_last_error()返回0.謝謝你的回覆 – 2014-11-02 13:57:58