3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements ArrayAccess { protected $items = []; public function __construct(array $items) { $this->items = $items; } public function offsetExists($offset) { return array_key_exists($offset, $this->items); } public function offsetGet($offset) { return $this->items[$offset]; } public function offsetSet($key, $value) { if (is_null($key)) { $this->items[] = $value; } else { $this->items[$key] = $value; } } public function offsetUnset($key) { unset($this->items[$key]); } } $arr = ['a' => null]; $coll = new Collection($arr); var_dump(isset($arr['a']), isset($coll['a']));

preferences:
37.31 ms | 404 KiB | 5 Q