3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arrays = [ ['car' => '3', 'bus' => '2'], ['dog' => '1', 'car' => '2', 'bird' => '9'], ]; $defaults = array_fill(0, count($arrays), null); $result = []; foreach ($arrays as $i => $array) { foreach ($array as $k => $v){ $result[$k] ??= $defaults; $result[$k][$i] = $v; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 27
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 27
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 25
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 25
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/Asek6
function name:  (null)
number of ops:  32
compiled vars:  !0 = $arrays, !1 = $defaults, !2 = $result, !3 = $array, !4 = $i, !5 = $v, !6 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        INIT_FCALL                                               'array_fill'
          2        SEND_VAL                                                 0
          3        COUNT                                            ~8      !0
          4        SEND_VAL                                                 ~8
          5        SEND_VAL                                                 null
          6        DO_ICALL                                         $9      
          7        ASSIGN                                                   !1, $9
    9     8        ASSIGN                                                   !2, <array>
   10     9      > FE_RESET_R                                       $12     !0, ->27
         10    > > FE_FETCH_R                                       ~13     $12, !3, ->27
         11    >   ASSIGN                                                   !4, ~13
   11    12      > FE_RESET_R                                       $15     !3, ->25
         13    > > FE_FETCH_R                                       ~16     $15, !5, ->25
         14    >   ASSIGN                                                   !6, ~16
   12    15        FETCH_DIM_IS                                     ~18     !2, !6
         16        COALESCE                                         ~19     ~18
         17        ASSIGN_DIM                                       ~20     !2, !6
         18        OP_DATA                                                  !1
         19        QM_ASSIGN                                        ~19     ~20
         20        FREE                                                     ~19
   13    21        FETCH_DIM_W                                      $21     !2, !6
         22        ASSIGN_DIM                                               $21, !4
         23        OP_DATA                                                  !5
   11    24      > JMP                                                      ->13
         25    >   FE_FREE                                                  $15
   10    26      > JMP                                                      ->10
         27    >   FE_FREE                                                  $12
   16    28        INIT_FCALL                                               'var_export'
         29        SEND_VAR                                                 !2
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.77 ms | 1012 KiB | 15 Q