3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = Array ( 0 => Array ( 'template_id' => 1, 'template_field_id' => 20 ), 1 => Array ( 'template_id' => 1, 'template_field_id' => 21 ), 2 => Array ( 'template_id' => 2, 'template_field_id' => 22 ), 3 => Array ( 'template_id' => 2, 'template_field_id' => 23 ) ); $newarr = array(); foreach($arr as $key=>$val){ $newarr[$val['template_id']][] = $val; } $i=0; foreach($newarr as $k=>$v){ foreach($v as $m){ $newarr1[$i]['id']= $m['template_id']; $newarr1[$i]['template_field_id'][]['id']= $m['template_field_id']; } $i++; } echo "<pre>"; print_r($newarr1);
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [0] => Array ( [id] => 1 [template_field_id] => Array ( [0] => Array ( [id] => 20 ) [1] => Array ( [id] => 21 ) ) ) [1] => Array ( [id] => 2 [template_field_id] => Array ( [0] => Array ( [id] => 22 ) [1] => Array ( [id] => 23 ) ) ) )

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