3v4l.org

run code in 300+ PHP versions simultaneously
<?php $items = [ (object) ['group_id' => 'a', 'price' => 10, 'options_count' => 3], (object) ['group_id' => 'a', 'price' => 15, 'options_count' => 2], (object) ['group_id' => 'b', 'price' => 55, 'options_count' => 4], (object) ['group_id' => 'c', 'price' => 75, 'options_count' => 5], ]; $totals = []; foreach($items as $item) { $group_identifier = $item->group_id; @$totals[ $group_identifier ]['turnover'] += $item->price; @$totals[ $group_identifier ]['products']++; @$totals[ $group_identifier ]['options'] += $item->options_count; } var_dump($totals);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 32
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 32
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/efuNV
function name:  (null)
number of ops:  37
compiled vars:  !0 = $items, !1 = $totals, !2 = $item, !3 = $group_identifier
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   CAST                                          8  ~4      <array>
          1        INIT_ARRAY                                       ~5      ~4
    5     2        CAST                                          8  ~6      <array>
          3        ADD_ARRAY_ELEMENT                                ~5      ~6
    6     4        CAST                                          8  ~7      <array>
          5        ADD_ARRAY_ELEMENT                                ~5      ~7
    7     6        CAST                                          8  ~8      <array>
          7        ADD_ARRAY_ELEMENT                                ~5      ~8
    3     8        ASSIGN                                                   !0, ~5
   12     9        ASSIGN                                                   !1, <array>
   14    10      > FE_RESET_R                                       $11     !0, ->32
         11    > > FE_FETCH_R                                               $11, !2, ->32
   16    12    >   FETCH_OBJ_R                                      ~12     !2, 'group_id'
         13        ASSIGN                                                   !3, ~12
   18    14        BEGIN_SILENCE                                    ~14     
         15        FETCH_OBJ_R                                      ~17     !2, 'price'
         16        FETCH_DIM_RW                                     $15     !1, !3
         17        ASSIGN_DIM_OP                +=               1          $15, 'turnover'
         18        OP_DATA                                                  ~17
         19        END_SILENCE                                              ~14
   19    20        BEGIN_SILENCE                                    ~18     
         21        FETCH_DIM_RW                                     $19     !1, !3
         22        FETCH_DIM_RW                                     $20     $19, 'products'
         23        PRE_INC                                                  $20
         24        END_SILENCE                                              ~18
   20    25        BEGIN_SILENCE                                    ~22     
         26        FETCH_OBJ_R                                      ~25     !2, 'options_count'
         27        FETCH_DIM_RW                                     $23     !1, !3
         28        ASSIGN_DIM_OP                +=               1          $23, 'options'
         29        OP_DATA                                                  ~25
         30        END_SILENCE                                              ~22
   14    31      > JMP                                                      ->11
         32    >   FE_FREE                                                  $11
   23    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !1
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
239.44 ms | 1070 KiB | 14 Q