Many people get "Fatal error: Cannot use object of type stdClass as array in..." when PHP outputs a two-dimensional array.
The solution analysis is as follows:
There is a two-dimensional array like this:
Copy code The code is as follows:
Array (
[0] => stdClass Object (
[id] = > 1
[title] => Recruitment Information
[size] => 300*150
[pic] => ./upload/20140602093535.jpg
[state] => ; 0 )
[1] => stdClass Object (
[id] => > [pic] => ./upload/20140602093443.jpg
[state] => 0 )
)
The method to start writing the output is: $pic[0][title]
The above error appears as a result.
Actually, an object is returned in the array and cannot be displayed directly with []. The correct output method is: $pic[0]->title
Problem solved!
http://www.bkjia.com/PHPjc/788613.html
www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/788613.htmlTechArticleMany people get "Fatal error: Cannot use object of type stdClass as array" when PHP outputs a two-dimensional array. in…”. The solution is analyzed as follows: There is such a two-dimensional number...