I have an object (stored as $videos) that looks like this
object(stdClass)#19 (3) {
[0]=>
object(stdClass)#20 (22) {
[\"id\"]=>
string(1) \
Playing with Php interactive shell, Php 7:
➜ ~ php -a
Interactive shell
php > $v = (object) ["toto" => "hello"];
php > var_dump($v);
object(stdClass)#1 (1) {
["toto"]=>
string(5) "hello"
}
php > echo $v{0};
PHP Warning: Uncaught Error: Cannot use object of type stdClass as array in php shell code:1
Stack trace:
#0 {main}
thrown in php shell code on line 1
Warning: Uncaught Error: Cannot use object of type stdClass as array in php shell code:1
Stack trace:
#0 {main}
thrown in php shell code on line 1
php > echo $v->{0};
PHP Notice: Undefined property: stdClass::$0 in php shell code on line 1
Notice: Undefined property: stdClass::$0 in php shell code on line 1
php > echo current($v);
hello
Only current
is working with object.