Tag Archives: object

Create a PHP data structure accessible like an array and an object simultaneously

Often we need to operate with objects that sometimes we have to use as an array.
For example we can get an attribute from an object:

$attr = $myObject->attr;

or by array access from the same object

$attr = $myObject['attr'];

We can set data simply like an array or directly.