From PHP 5.3 we can use some amazing new interfaces so magical. One of them is ArrayAccess. This interface provides a set of methods that we can use to implement the array behavior in a stdClass. Let’s see an example:

How does it work? In the example above, I’ve already loaded some items in the internal array. Let’s what we can do:

Next, we can add the __set() magic method as well:

and then: