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));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 17
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 17
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/e6V3Y
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $row, !2 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   10     1      > FE_RESET_R                                       $4      !0, ->17
          2    > > FE_FETCH_R                                               $4, !1, ->17
   11     3    >   FETCH_DIM_R                                      ~5      !1, 'day'
          4        ISSET_ISEMPTY_DIM_OBJ                         0  ~6      !2, ~5
          5        BOOL_NOT                                         ~7      ~6
          6      > JMPZ                                                     ~7, ->11
   12     7    >   FETCH_DIM_R                                      ~8      !1, 'day'
          8        ASSIGN_DIM                                               !2, ~8
          9        OP_DATA                                                  !1
         10      > JMP                                                      ->16
   14    11    >   FETCH_DIM_R                                      ~10     !1, 'day'
         12        FETCH_DIM_R                                      ~13     !1, 'movements'
         13        FETCH_DIM_RW                                     $11     !2, ~10
         14        ASSIGN_DIM_OP                +=               1          $11, 'movements'
         15        OP_DATA                                                  ~13
   10    16    > > JMP                                                      ->2
         17    >   FE_FREE                                                  $4
   17    18        INIT_FCALL                                               'var_export'
         19        INIT_FCALL                                               'array_values'
         20        SEND_VAR                                                 !2
         21        DO_ICALL                                         $14     
         22        SEND_VAR                                                 $14
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.29 ms | 1396 KiB | 17 Q