3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ObjectKeyIterator extends IteratorIterator { public function __construct(\Traversable $iterator) { parent::__construct($iterator); } public function key() { $key = parent::key(); return (object)array('key' => $key); } } /*foreach(new ObjectKeyIterator(new ArrayObject(array('test' => 'foo', 2,4, 'bo' => 24,2))) as $key => $value) { var_dump($key, $value); }*/ $iterator = new ObjectKeyIterator(new ArrayObject(array('test' => 'foo', 2,4, 'bo' => 24,2))); $iterator->rewind(); while ($iterator->valid()) { $key = $iterator->key(); $value = $iterator->current(); var_dump($key, $value); $iterator->next(); }
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of ObjectKeyIterator::key() should either be compatible with IteratorIterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/7mXic on line 9 object(stdClass)#5 (1) { ["key"]=> string(4) "test" } string(3) "foo" object(stdClass)#6 (1) { ["key"]=> int(0) } int(2) object(stdClass)#5 (1) { ["key"]=> int(1) } int(4) object(stdClass)#6 (1) { ["key"]=> string(2) "bo" } int(24) object(stdClass)#5 (1) { ["key"]=> int(2) } int(2)

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:
45.6 ms | 402 KiB | 8 Q