3v4l.org

run code in 300+ PHP versions simultaneously
<?php class JupilerLeague extends SplHeap { /** * We modify the abstract method compare so we can sort our * rankings using the values of a given array */ public function compare($array1, $array2) { $values1 = array_values($array1); $values2 = array_values($array2); if ($values1[0] === $values2[0]) return 0; return $values1[0] < $values2[0] ? -1 : 1; } } // Let's populate our heap here (data of 2009) $heap = new JupilerLeague(); $heap->insert(array ('AA Gent' => 15)); $heap->insert(array ('Anderlecht' => 20)); $heap->insert(array ('Cercle Brugge' => 11)); $heap->insert(array ('Charleroi' => 12)); $heap->insert(array ('Club Brugge' => 21)); $heap->insert(array ('G. Beerschot' => 15)); print_r(iterator_to_array($heap)); print_r(iterator_to_array($heap));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Return type of JupilerLeague::compare($array1, $array2) should either be compatible with SplHeap::compare(mixed $value1, mixed $value2): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /in/KkdZ4 on line 9 Array ( [5] => Array ( [Club Brugge] => 21 ) [4] => Array ( [Anderlecht] => 20 ) [3] => Array ( [AA Gent] => 15 ) [2] => Array ( [G. Beerschot] => 15 ) [1] => Array ( [Charleroi] => 12 ) [0] => Array ( [Cercle Brugge] => 11 ) ) Array ( )

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