3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ids = [1, 1, 1, 2, 5, 1]; $sizes = ["m", "m", "m", "s", "xl", "s"]; $colors = ["red", "red", "yellow", "orange", "red", "orange"]; foreach ($ids as $i => $id) { $size = $sizes[$i]; $color = $colors[$i]; $tempKey = "{$id}:{$size}:{$color}"; if (!isset($result[$tempKey])) { $result[$tempKey] = [ 'id' => $id, 'size' => $size, 'color' => $color, 'stock' => 1 ]; } else { ++$result[$tempKey]['stock']; } } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 30
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/F96NL
function name:  (null)
number of ops:  38
compiled vars:  !0 = $ids, !1 = $sizes, !2 = $colors, !3 = $id, !4 = $i, !5 = $size, !6 = $color, !7 = $tempKey, !8 = $result
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    7     3      > FE_RESET_R                                       $12     !0, ->30
          4    > > FE_FETCH_R                                       ~13     $12, !3, ->30
          5    >   ASSIGN                                                   !4, ~13
    8     6        FETCH_DIM_R                                      ~15     !1, !4
          7        ASSIGN                                                   !5, ~15
    9     8        FETCH_DIM_R                                      ~17     !2, !4
          9        ASSIGN                                                   !6, ~17
   10    10        ROPE_INIT                                     5  ~20     !3
         11        ROPE_ADD                                      1  ~20     ~20, '%3A'
         12        ROPE_ADD                                      2  ~20     ~20, !5
         13        ROPE_ADD                                      3  ~20     ~20, '%3A'
         14        ROPE_END                                      4  ~19     ~20, !6
         15        ASSIGN                                                   !7, ~19
   11    16        ISSET_ISEMPTY_DIM_OBJ                         0  ~24     !8, !7
         17        BOOL_NOT                                         ~25     ~24
         18      > JMPZ                                                     ~25, ->26
   13    19    >   INIT_ARRAY                                       ~27     !3, 'id'
   14    20        ADD_ARRAY_ELEMENT                                ~27     !5, 'size'
   15    21        ADD_ARRAY_ELEMENT                                ~27     !6, 'color'
   16    22        ADD_ARRAY_ELEMENT                                ~27     1, 'stock'
   12    23        ASSIGN_DIM                                               !8, !7
   16    24        OP_DATA                                                  ~27
         25      > JMP                                                      ->29
   19    26    >   FETCH_DIM_RW                                     $28     !8, !7
         27        FETCH_DIM_RW                                     $29     $28, 'stock'
         28        PRE_INC                                                  $29
    7    29    > > JMP                                                      ->4
         30    >   FE_FREE                                                  $12
   22    31        INIT_FCALL                                               'var_export'
         32        INIT_FCALL                                               'array_values'
         33        SEND_VAR                                                 !8
         34        DO_ICALL                                         $31     
         35        SEND_VAR                                                 $31
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.73 ms | 1404 KiB | 17 Q