I'm trying to extend the SPL ArrayObject but I've hit a little snag. Using an unmodified ArrayObject, this code works:
$a = new ArrayObject();
$a[1][2] = 'abc';
print_r($a);
yielding this output:
ArrayObject Object
(
[storage:ArrayObject:private] => Array
(
[1] => Array
(
[2] => abc
)
)
)
However if I extend ArrayObject and overload the offsetGet method
class ExtendedArray extends ArrayObject {
function offsetGet($i) {
return parent::offsetGet($i);
}
}
$a = new ExtendedArray();
$a[1][2] = 'abc';
print_r($a);
it then fails like this:
ExtendedArray Object
(
[storage:ArrayObject:private] => Array
(
)
)
What does it take to make my extended class work with multidimensional arrays?