3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [[ "continent" => "Europa", "country" => "France", "capital" => "Paris", ],[ "continent" => "Europa", "country" => "Spain", "capital" => "Madrid", ],[ "continent" => "Asia", "country" => "Russia", "capital" => "Moscow", ]]; $groupByContinent = function(array $list) { return array_reduce($list, function($grouped, $item) { $grouped[$item['continent']][] = $item; return $grouped; }, []); }; $groupedByContinent = $groupByContinent($data); var_dump($groupedByContinent);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { ["Europa"]=> array(2) { [0]=> array(3) { ["continent"]=> string(6) "Europa" ["country"]=> string(6) "France" ["capital"]=> string(5) "Paris" } [1]=> array(3) { ["continent"]=> string(6) "Europa" ["country"]=> string(5) "Spain" ["capital"]=> string(6) "Madrid" } } ["Asia"]=> array(1) { [0]=> array(3) { ["continent"]=> string(4) "Asia" ["country"]=> string(6) "Russia" ["capital"]=> string(6) "Moscow" } } }

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:
37.38 ms | 406 KiB | 5 Q