3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayClass implements ArrayAccess { private $container = []; public function __construct(array $array) { $this->container = $array; } public function offsetSet($offset, $value) { if (is_null($offset)) { $this->container[] = $value; } else { $this->container[$offset] = $value; } } public function offsetExists($offset) { return isset($this->container[$offset]); } public function offsetUnset($offset) { unset($this->container[$offset]); } public function offsetGet($offset) { return $this->offsetExists($offset) ? $this->container[$offset] : false; } } $_POST['aa'] = "dd"; $_POST['bb'] = "xd"; $post = new ArrayClass($_POST); print_r( [ $post['aa'], $post['bb'], $post['cc'], $post ] );

preferences:
15.86 ms | 402 KiB | 5 Q