3v4l.org

run code in 300+ PHP versions simultaneously
<?php $stores = [ 0 => "store3", 1 => "store", 2 => "store2" ]; $products = [ 0 => [ "store" => "store", "product" => "1" ], 1 => [ "store" => "store", "product" => "4" ], 2 => [ "store" => "store2", "product" => "2" ], 3 => [ "store" => "store2", "product" => "3" ], 4 => [ "store" => "store3", "product" => "7" ], 5 => [ "store" => "store3", "product" => "11" ] ]; $array = []; array_walk($products, function ($value, $key) use ($stores, &$array) { $array[$value['store']][] = $value['product']; }); print_r($array);
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [store] => Array ( [0] => 1 [1] => 4 ) [store2] => Array ( [0] => 2 [1] => 3 ) [store3] => Array ( [0] => 7 [1] => 11 ) )

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