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 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.28, 8.4.1 - 8.4.14, 8.5.0 - 8.5.1
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 ) )
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.

preferences:
188.77 ms | 408 KiB | 5 Q