3v4l.org

run code in 500+ PHP versions simultaneously
<?php $arr= [ ['attr_id' => 1,'name' => 'qty','value' =>'100'], ['attr_id' => 1,'name'=>'qty','value'=>'200'], ['attr_id'=>1,'name'=>'qty','value'=>'500'], ['attr_id'=>2,'name'=>'price','value'=>'10$']]; $value = array_column($arr, 'value'); $id = array_column($arr, 'attr_id'); $res =[]; Foreach($id as $key => $i){ If(!isset($res[$i])) $res[$i] = ['attr_id' => $i, 'name'=>'qty', 'value' => []]; $res[$i]['value'][] = $value[$key]; } Var_dump($res);
Output for git.master, git.master_jit, rfc.property-hooks
array(2) { [1]=> array(3) { ["attr_id"]=> int(1) ["name"]=> string(3) "qty" ["value"]=> array(3) { [0]=> string(3) "100" [1]=> string(3) "200" [2]=> string(3) "500" } } [2]=> array(3) { ["attr_id"]=> int(2) ["name"]=> string(3) "qty" ["value"]=> array(1) { [0]=> string(3) "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:
42.15 ms | 1486 KiB | 4 Q