3v4l.org

run code in 500+ 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));
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/paqNF
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>
    7     1      > FE_RESET_R                                           $4      !0, ->17
          2    > > FE_FETCH_R                                                   $4, !1, ->17
    8     3    >   FETCH_DIM_R                                          ~5      !1, 'currency'
          4        ISSET_ISEMPTY_DIM_OBJ                             0  ~6      !2, ~5
          5        BOOL_NOT                                             ~7      ~6
          6      > JMPZ                                                         ~7, ->11
    9     7    >   FETCH_DIM_R                                          ~8      !1, 'currency'
          8        ASSIGN_DIM                                                   !2, ~8
          9        OP_DATA                                                      !1
    8    10      > JMP                                                          ->16
   11    11    >   FETCH_DIM_R                                          ~10     !1, 'currency'
         12        FETCH_DIM_R                                          ~13     !1, 'Totalcs'
         13        FETCH_DIM_RW                                         $11     !2, ~10
         14        ASSIGN_DIM_OP                    +=               1          $11, 'Totalcs'
         15        OP_DATA                                                      ~13
    7    16    > > JMP                                                          ->2
         17    >   FE_FREE                                                      $4
   14    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.5.0


preferences:
160 ms | 2623 KiB | 15 Q