3v4l.org

run code in 300+ PHP versions simultaneously
<?php $food = Array ( 'Joe' => Array ( 0 => 'Pizza', 1 => 'Pasta', 2 => 'Lasagne', 3 => 'Tacos', 4 => 'Hamburger' ), 'Conny' => Array ( 0 => 'Pizza', 1 => 'Pasta', 2 => 'Lasagne', 3 => 'Tacos', 4 => 'Hamburger' ), 'John' => Array ( 0 => 'Pizza', 1 => 'Pasta' ), 'Fred' => Array ( 0 => 'Pizza', 1 => 'Pasta', 2 => 'Soup', 3 => 'Fish' ), 'Greg' => Array ( 0 => 'Sushi' ) ); uasort($food, function($a, $b) { return count($b) <=> count($a); }); $used = array(); foreach($food as $kl => $pl) { foreach($pl as $k => $p) { if(!in_array($p, $used)) { $used[] = $p; } else { unset($food[$kl][$k]); } } } $food = array_filter($food); var_dump($food);
Output for git.master, git.master_jit, rfc.property-hooks
array(3) { ["Joe"]=> array(5) { [0]=> string(5) "Pizza" [1]=> string(5) "Pasta" [2]=> string(7) "Lasagne" [3]=> string(5) "Tacos" [4]=> string(9) "Hamburger" } ["Fred"]=> array(2) { [2]=> string(4) "Soup" [3]=> string(4) "Fish" } ["Greg"]=> array(1) { [0]=> string(5) "Sushi" } }

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