3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=[ ['day'=>'11','movements'=>'1'], ['day'=>'11','movements'=>'1'], ['day'=>'11','movements'=>'1'], ['day'=>'12','movements'=>'1'], ['day'=>'12','movements'=>'1'], ['day'=>'12','movements'=>'1'] ]; foreach($array as $row){ // iterate all rows if(!isset($result[$row['day']])){ // if first occurrence of day... $result[$row['day']]=$row; // save the full row with day as the temporary key }else{ // if not the first occurrence of day... $result[$row['day']]['movements']+=$row['movements']; // add movements value } } var_export(array_values($result));
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.26, 8.0.0 - 8.0.13, 8.1rc1 - rc3
array ( 0 => array ( 'day' => '11', 'movements' => 3, ), 1 => array ( 'day' => '12', 'movements' => 3, ), )

preferences:
38.15 ms | 461 KiB | 5 Q