3v4l.org

run code in 500+ PHP versions simultaneously
<?php $color = [ ['id' => 1, 'color' => 'red'], ['id' => 2, 'color' => 'green'], ['id' => 3, 'color' => 'blue'], ]; $size = [ ['id' => 1, 'size' => 'SM'], ['id' => 2, 'size' => 'XL'], ['id' => 4, 'size' => 'LG'], ['id' => 3, 'size' => 'MD'], ]; foreach(array_merge($color, $size) as $el){ $merged[$el['id']] = ($merged[$el['id']] ?? []) + $el; } var_export($merged);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 17
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/7iqjt
function name:  (null)
number of ops:  22
compiled vars:  !0 = $color, !1 = $size, !2 = $el, !3 = $merged
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    9     1        ASSIGN                                                       !1, <array>
   16     2        INIT_FCALL                                                   'array_merge'
          3        SEND_VAR                                                     !0
          4        SEND_VAR                                                     !1
          5        DO_ICALL                                             $6      
          6      > FE_RESET_R                                           $7      $6, ->17
          7    > > FE_FETCH_R                                                   $7, !2, ->17
   17     8    >   FETCH_DIM_R                                          ~8      !2, 'id'
          9        FETCH_DIM_R                                          ~10     !2, 'id'
         10        FETCH_DIM_IS                                         ~11     !3, ~10
         11        COALESCE                                             ~12     ~11
         12        QM_ASSIGN                                            ~12     <array>
         13        ADD                                                  ~13     ~12, !2
         14        ASSIGN_DIM                                                   !3, ~8
         15        OP_DATA                                                      ~13
   16    16      > JMP                                                          ->7
         17    >   FE_FREE                                                      $7
   20    18        INIT_FCALL                                                   'var_export'
         19        SEND_VAR                                                     !3
         20        DO_ICALL                                                     
         21      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
224.97 ms | 2209 KiB | 15 Q