class DotAccessArray implements ArrayAccess {
private $items = array();
public function offsetExists($k) {
$k = explode('.', $k, 2);
return isset($this -> items[$k[0]][$k[1]]);
}
public function offsetGet($k) {
$k = explode('.', $k, 2);
if (isset($this -> items[$k[0]])) {
if (count($k) > 1) return $this -> items[$k[0]][$k[1]];
return $this -> items[$k[0]];
}
return null;
}
public function offsetSet($k, $v) {
$k = explode('.', $k, 2);
if (count($k) > 1) {
if (!isset($this -> items[$k[0]])) $this -> items[$k[0]] = new static();
$this -> items[$k[0]][$k[1]] = $v;
}
else $this -> items[$k[0]] = $v;
}
public function offsetUnset($k) {
$k = explode('.', $k, 2);
if (count($k) > 1) {
unset($this -> items[$k[0]][$k[1]]);
}
else unset($this -> items[$k[0]]);
}
}