- var_dump: documentation ( source)
<?php
class App_Collection implements ArrayAccess, IteratorAggregate, Countable
{
public $data = array('x'=>'a');
public function count()
{
return count($this->data);
}
public function offsetExists($offset)
{
return isset($this->data[$offset]) || array_key_exists($offset, $this->data);
}
public function offsetGet($offset)
{
if ($this->offsetExists($offset))
{
return $this->data[$offset];
}
return false;
}
public function offsetSet($offset, $value)
{
if ($offset)
{
$this->data[$offset] = $value;
}
else
{
$this->data[] = $value;
}
}
public function offsetUnset($offset)
{
unset($this->data[$offset]);
}
public function getIterator()
{
return new ArrayIterator($this->data);
}
}
$array = new App_Collection();
var_dump(isset($array['x']));
var_dump(array_key_exists('x', $array));