3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ "Jacob" => 5, "bob" => 20, "John" => 10, "Jane" => 20, "Jill" => 15, ]; $limit = 3; arsort($array); $result = []; foreach ($array as $k => $v) { if (count($result) === $limit && !isset($result[$v])) { break; } $result[$v][$k] = $v; } var_export(array_values($result));
Output for git.master, git.master_jit
array ( 0 => array ( 'bob' => 20, 'Jane' => 20, ), 1 => array ( 'Jill' => 15, ), 2 => array ( 'John' => 10, ), )

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:
39.69 ms | 995 KiB | 4 Q