3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayExtended implements ArrayAccess{ protected $ary = array(); public function __construct(array $a = null) { if($a) $this->ary = $a; } // Useful methods public function reverse() { $this->ary = array_reverse($this->ary); return $this; } // Mandatory methods for ArrayAccess implementation public function offsetExists($off){} public function offsetGet($off){} public function offsetSet($off,$val){} public function offsetUnset($off){} } $o = new ArrayExtended(array('a','b')); $o[] = 'c'; print_r($o);

preferences:
56.76 ms | 402 KiB | 5 Q