3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = new stdClass(); $obj->id = ['a', 'b', 'a', 'c']; $obj->type = ['aaa', 'bbb', 'aaa', 'aaa']; $obj->num = [95, 100, 50, 11]; $sum = []; foreach($obj->id as $idx => $id) { if(!array_key_exists($id, $sum)) { $sum[$id] = []; } $sum[$obj->type[$id]] += $obj->num; } var_dump($sum);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 19
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/V7KoB
function name:  (null)
number of ops:  30
compiled vars:  !0 = $obj, !1 = $sum, !2 = $id, !3 = $idx
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $4      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $4
    4     3        ASSIGN_OBJ                                               !0, 'id'
          4        OP_DATA                                                  <array>
    5     5        ASSIGN_OBJ                                               !0, 'type'
          6        OP_DATA                                                  <array>
    6     7        ASSIGN_OBJ                                               !0, 'num'
          8        OP_DATA                                                  <array>
    7     9        ASSIGN                                                   !1, <array>
    8    10        FETCH_OBJ_R                                      ~11     !0, 'id'
         11      > FE_RESET_R                                       $12     ~11, ->25
         12    > > FE_FETCH_R                                       ~13     $12, !2, ->25
         13    >   ASSIGN                                                   !3, ~13
    9    14        ARRAY_KEY_EXISTS                                 ~15     !2, !1
         15        BOOL_NOT                                         ~16     ~15
         16      > JMPZ                                                     ~16, ->19
   10    17    >   ASSIGN_DIM                                               !1, !2
         18        OP_DATA                                                  <array>
   12    19    >   FETCH_OBJ_R                                      ~18     !0, 'type'
         20        FETCH_DIM_R                                      ~19     ~18, !2
         21        FETCH_OBJ_R                                      ~21     !0, 'num'
         22        ASSIGN_DIM_OP                +=               1          !1, ~19
         23        OP_DATA                                                  ~21
    8    24      > JMP                                                      ->12
         25    >   FE_FREE                                                  $12
   14    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.74 ms | 1388 KiB | 15 Q