3v4l.org

run code in 300+ PHP versions simultaneously
<?php class ArrayAsKeyIterator extends IteratorIterator { public function key() { return array('1', parent::key()); } } $it = new ArrayAsKeyIterator(new ArrayIterator(range(0, 1))); iterator_count($it); $it->rewind(); $it->key(); var_dump($it->current(), $it->key()); $array = iterator_to_array($it, FALSE); // because it is wrapped into an iterator iterator, see: $itit = new IteratorIterator($it); $array = iterator_to_array($itit, FALSE);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of ArrayAsKeyIterator::key() should either be compatible with IteratorIterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/7mIvr on line 4 int(0) array(2) { [0]=> string(1) "1" [1]=> int(0) }

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