3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $iterator = new ArrayIterator([new Test(10), new Test(1), new Test(5)]); $iterator->uasort( function ($first, $second) { return $first->getSortOrder() < $second->getSortOrder() ? -1 : 1; } ); $collection = new ArrayCollection(iterator_to_array($iterator)); var_dump($collection->getValues()); die; class Test { private $orderNr; function __construct($orderNr) { $this->orderNr = $orderNr; } public function getSortOrder() { return $this->orderNr; } }
based on 8NV65
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Error: Class 'ArrayCollection' not found in /in/Shrqg:11 Stack trace: #0 {main} thrown in /in/Shrqg on line 11
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Fatal error: Class 'ArrayCollection' not found in /in/Shrqg on line 11
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[', expecting ')' in /in/Shrqg on line 3
Process exited with code 255.