3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array ( "100" => array( array( "country" => 'France', "city" => 'Paris', "population" => '1800000', ), array( "country" => 'France', "city" => 'Paris', "population" => '2000000', ), array( "country" => 'France', "city" => 'Toulouse', "population" => '500000', ), ), "101" => array( array( "country" => 'Russia', "city" => 'Moscow', "population" => '144000000', ) ) ); foreach($arr as $k => &$ar) { $mins = array_reduce($ar, function ($carry, $item) { $key = $item["country"] . "###" . $item["city"]; $carry[$key] = (isset($carry[$key]) && $item["population"] > $carry[$key]) ? $carry[$key] : $item["population"]; return $carry; }, []); $ar = array_filter($ar, function ($item) use ($mins) { $key = $item["country"] . "###" . $item["city"]; return $mins[$key] == $item["population"]; }); } print_r($arr);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [100] => Array ( [0] => Array ( [country] => France [city] => Paris [population] => 1800000 ) [2] => Array ( [country] => France [city] => Toulouse [population] => 500000 ) ) [101] => Array ( [0] => Array ( [country] => Russia [city] => Moscow [population] => 144000000 ) ) )

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:
159.87 ms | 407 KiB | 5 Q