3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array( array('setid'=>1,'income'=>100), array('setid'=>1,'income'=>120), array('setid'=>2,'income'=>100), ); $values = array(); foreach($array as $val) { if(isset($values[$val['setid']])) { $values[$val['setid']] += $val['income']; } else { $values[$val['setid']] = $val['income']; } } var_dump($values);
Output for 4.3.0 - 7.1.0
array(2) { [1]=> int(220) [2]=> int(100) }