Possible Duplicate:
Fatal error: Cannot use object of type stdClass as array in不能使用類型爲stdClass的對象爲數組(PHP)
請我不斷收到此錯誤: 致命錯誤:無法使用類型stdClass的對象在C數組:\ XAMMP \ XAMPP \ htdocs中\ Yemi \上線31
這geograph \ table.php是我試圖運行PHP:
Possible Duplicate:
Fatal error: Cannot use object of type stdClass as array in不能使用類型爲stdClass的對象爲數組(PHP)
請我不斷收到此錯誤: 致命錯誤:無法使用類型stdClass的對象在C數組:\ XAMMP \ XAMPP \ htdocs中\ Yemi \上線31
這geograph \ table.php是我試圖運行PHP:
你實際上是試圖訪問對象數組。
我猜你是當您使用json_decode
它返回一個對象和foreach
循環內您要訪問它像一個關聯數組有問題。
將第二個參數作爲true
傳遞給json_decode
強制它返回關聯數組。
進行以下更改。
更改這行代碼
$items = json_decode($contents);
要
$items = json_decode($contents, true);
@點擊謝謝......像魅力一樣工作 – akinboj 2012-03-03 13:43:12
請粘貼在這裏實際代碼,而不是一些你的代碼截圖。謝謝 – 2012-03-03 13:11:30
是的,請張貼實際的代碼。我們嚴重依賴複製/粘貼代碼示例來提供錯誤修正和註釋的答案。 – 2012-03-03 13:24:34
「點擊」的響應解決了問題。問題回答了。論壇請注意... – akinboj 2012-03-03 13:50:05