3v4l.org

run code in 300+ PHP versions simultaneously
<?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));

preferences:
47.83 ms | 402 KiB | 5 Q