3v4l.org

run code in 300+ PHP versions simultaneously
<?php function accept_array($a) : void { var_dump($a); unset($a); } function return_array() { return new class implements ArrayAccess { public function offsetExists(mixed $offset): bool { return true; } public function offsetGet(mixed $offset): mixed { return 42; } public function offsetSet(mixed $offset, mixed $value): void {} public function offsetUnset(mixed $offset): void {} }; } $input = return_array(); if (isset($input['key'])) { accept_array($input); }
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.23, 8.3.0 - 8.3.11
object(ArrayAccess@anonymous)#1 (0) { }

preferences:
55.08 ms | 406 KiB | 5 Q