我試圖插入生成的字符串到後來被用於實施JSON數組的破滅問題將字符串到數組
產生的破滅字符串看起來像這樣
'id' => $this->_SqlResult[0],'UserId' => $this->_SqlResult[1],'Msg' => $this->_SqlResult[2],'MsgStamp' => $this->_SqlResult[3]
我會想用它在這個代碼
$this->_JsonArr[]=array($Generated string);
實現這樣的
$this->_JsonArr[]=array('id' => $this->_SqlResult[0],'UserId' => $this->_SqlResult[1],'Msg' => $this->_SqlResult[2],'MsgStamp' => $this->_SqlResult[3]);
代替我有像這樣
$this->_JsonArr[]=array(" 'id' => $this->_SqlResult[0],'UserId' => $this->_SqlResult[1],'Msg' => $this->_SqlResult[2],'MsgStamp' => $this->_SqlResult[3]");
看起來像生成的字符串作爲一個元素作爲鍵和值的對治療。 顯然我可以得到預期的輸出,因爲這一點,任何人都可以幫助我這個
我認爲(只是瘋狂的猜測)OP在json中提供數據時會感到困惑(因此將數組內嵌入字符串中)。因此,作爲@zul不要忘記'echo json_encode($ this - > _ JsonArr)'輸出帶有數據的字符串。 – 2011-04-22 12:06:33