I have an object (stored as $videos) that looks like this
object(stdClass)#19 (3) {
[0]=>
object(stdClass)#20 (22) {
["id"]=>
string(1) "123"
etc...
I want to get the ID of just that first element, without having to loop over it.
If it were an array, I would do this:
$videos[0]['id']
It used to work as this:
$videos[0]->id
But now I get an error "Cannot use object of type stdClass as array..." on the line shown above. Possibly due to a PHP upgrade.
So how do I get to that first ID without looping? Is it possible?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…