- var_dump: documentation ( source)
- array_values: documentation ( source)
<?php
class Ar implements ArrayAccess
{
private $storage = [];
private $offset = null;
public function __construct(array $ar)
{
$this->storage = array_values($ar);
$this->offset = 0;
}
public function offsetExists($offset)
{
return $offset <= count($this->storage);
}
public function offsetGet($offset)
{
return $this->storage[$offset];
}
public function offsetSet($offset, $value)
{
$this->storage[$offset] = $value;
}
public function offsetUnset($offset)
{
unset($this->storage[$offset]);
$this->storage = array_values($this->storage);
}
}
$obj = new Ar([1,2,3,4,5,6,7]);
var_dump(array_values($obj));