3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Collection implements IteratorAggregate { public function __construct(array $data) { $this->data = $data; } public function getIterator() { krsort($this->data); return new RecursiveIteratorIterator(new RecursiveArrayIterator($this->data)); } } $c = new Collection([ 10 => ['a', 'b'], 20 => ['c'], ]); var_dump(iterator_to_array($c));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of Collection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/4S7ts on line 7 Deprecated: Creation of dynamic property Collection::$data is deprecated in /in/4S7ts on line 5 array(2) { [0]=> string(1) "a" [1]=> string(1) "b" }

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