Reputation: 21
Is it possible to access to object member as if array member?
for example
echo $a->b;
to
echo $a[b];
Would it be any php ini settings, or this is quite impossible in PHP?
Upvotes: 1
Views: 51
Reputation: 78994
I tried for a one-liner but:
$x = (array)$a;
echo $x['b'];
Or of course to convert the object: $a = (array)$a;
Upvotes: 2
Reputation: 14530
extends ArrayObject
or implements ArrayAccess
so you can access the object as array.
Reading Material
Upvotes: 2