3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=[ ['currency'=>'bitcoin','Totalcs'=>'1'], ['currency'=>'ethereum','Totalcs'=>'1'], ['currency'=>'ethereum','Totalcs'=>'1'] ]; foreach($array as $row){ // iterate all rows if(!isset($result[$row['currency']])){ // if first occurrence of currency... $result[$row['currency']]=$row; // save the full row with currency as the temporary key }else{ // if not the first occurrence of currency... $result[$row['currency']]['Totalcs']+=$row['Totalcs']; // add Totalcs value } } var_export(array_values($result));
Output for git.master, git.master_jit, rfc.property-hooks
array ( 0 => array ( 'currency' => 'bitcoin', 'Totalcs' => '1', ), 1 => array ( 'currency' => 'ethereum', 'Totalcs' => 2, ), )

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:
45.77 ms | 401 KiB | 8 Q