- print_r: documentation ( source)
<?php
class test implements ArrayAccess {
public $v;
function __construct()
{
$this->v = array(
'a' => array('b' => 'c'),
'd' => array('e' => 'f'),
'g' => array('h' => 'i')
);
}
function offsetExists($offset)
{
return isset($this->v);
}
function &offsetGet($offset)
{
return isset($this->v[$offset]) ? $this->v[$offset] : null;
}
function offsetSet($offset, $value)
{
if (is_null($offset)) {
$this->v[] = $value;
} else {
$this->v[$offset] = $value;
}
}
function offsetUnset($offset)
{
unset($this->v[$offset]);
}
}
$test = new test();
$test['a']['b'] = 'zzz';
print_r($test->v);