3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(-1); ini_set('display_errors', 'On'); $helper = new class extends SplMinHeap { public function compare($a, $b): int { return ($b['current_qty'] + $b['add_qty']) <=> ($a['current_qty'] + $a['add_qty']); } }; $locations = [ ['location_name' => 'Toronto', 'current_qty' => 3, 'add_qty' => 0], ['location_name' => 'Mississauga', 'current_qty' => 7, 'add_qty' => 0], ['location_name' => 'London', 'current_qty' => 5, 'add_qty' => 0], ]; foreach ($locations as $entry) { $helper->insert($entry); } $qty = 10000; while ($qty-- > 0) { $min = $helper->extract(); $min['add_qty']++; $helper->insert($min); } print_r(iterator_to_array($helper));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [2] => Array ( [location_name] => Mississauga [current_qty] => 7 [add_qty] => 3331 ) [1] => Array ( [location_name] => London [current_qty] => 5 [add_qty] => 3333 ) [0] => Array ( [location_name] => Toronto [current_qty] => 3 [add_qty] => 3336 ) )

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:
186.43 ms | 406 KiB | 5 Q