3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayFoo implements ArrayAccess { public $data; public function __construct(array $data) { $this->data = $data; } public function offsetGet($index) { if (is_array($index)) { $temp = $this->data; foreach ($index as $key) { if (!isset($temp[$key])) return null; else $temp = $temp[$key]; } return $temp; } else { if (isset($this->data[$index])) return $this->data[$index]; else return null; } } public function offsetSet($index, $value) { } public function offsetExists($index) { } public function offsetUnset($index) { } } $tripla = new ArrayFoo(array( 'one' => array( 'does' => array( 'not' => array( 'simply' => array( 'walk' => array( 'into' => array( 'mordor' => 'Boromir' ) ) ) ) ) ) )); var_dump($tripla[array('one', 'does', 'not', 'simply', 'walk', 'into', 'mordor')]);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of ArrayFoo::offsetExists($index) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/agSMb on line 37 Deprecated: Return type of ArrayFoo::offsetGet($index) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/agSMb on line 12 Deprecated: Return type of ArrayFoo::offsetSet($index, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/agSMb on line 36 Deprecated: Return type of ArrayFoo::offsetUnset($index) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/agSMb on line 38 string(7) "Boromir"

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
47.73 ms | 404 KiB | 8 Q