When PHP outputs a two-dimensional array, "Fatalerror: CannotuseobjectoftypestdClassasarrayin…" appears ......". This article mainly introduces the solution to this error. if you need a friend, you can refer to the following: cannot use object of type stdClass as array in ......".
The solution is analyzed as follows:
There is a two-dimensional array:
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] => 2
[Title] => homepage headlines
[Size] => 300*150
[Pic] =>./upload/20140602093443.jpg
[State] => 0)
)
The method for writing the output is: $ pic [0] [title]
The above error occurs.
In fact, an object is returned in the array and cannot be directly displayed using []. the correct output method is: $ pic [0]-> title
Solve the problem!