3v4l.org

run code in 300+ PHP versions simultaneously
<?php class RouteCollection implements \IteratorAggregate { /** * @var Route[] */ public $routes = array(); /** * Gets the current RouteCollection as an Iterator that includes all routes. * * It implements \IteratorAggregate. * * @see all() * * @return \ArrayIterator An \ArrayIterator object for iterating over routes */ public function getIterator() { return new \ArrayIterator($this->routes); } } $c = new RouteCollection(); $o = new stdClass; $o->prio = 1; $c->routes[] = $o; $o = new stdClass; $o->prio = 5; $c->routes[] = $o; $c->getIterator()->uasort(function($a, $b) { if ($a->prio == $b->prio ) { return 0; } return $a->prio > $b->prio ? 1 : -1; } ); var_dump($c->routes);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of RouteCollection::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/fBCYA on line 19 array(2) { [0]=> object(stdClass)#2 (1) { ["prio"]=> int(1) } [1]=> object(stdClass)#3 (1) { ["prio"]=> int(5) } }

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