3v4l.org

run code in 300+ PHP versions simultaneously
<?php function mergeArray(array $arr1, array $arr2) { $keysStats = array(); foreach ($arr1 as $index => $key) { $keysStats[$key] = array( 'arr1' => $index, 'arr2' => null ); } foreach ($arr1 as $index => $key) { if (!is_array($keys[$key])) { $keysStats[$key] = array( 'arr1' => null ); } $keysStats[$key]['arr2'] = $index; } $merged = array(); foreach (sort($keysStats) as $key => $score) { if (is_null($keysStats['arr2'])) { $merged[] = null; } else { $merged[] = $arr2[$keysStats['arr2']]; } } return $arrMerged; } print_r(mergeArray( array( 'a', 'b', 'c', 'd', 'e', 'f', 'g' ), array( 'a', 'b', 'z', 'q' ) ));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ger3D
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL                                               'mergearray'
   36     2        SEND_VAL                                                 <array>
   39     3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   41     7      > RETURN                                                   1

Function mergearray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 11
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
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
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 21
Branch analysis from position: 25
2 jumps found. (Code = 77) Position 1 = 31, Position 2 = 44
Branch analysis from position: 31
2 jumps found. (Code = 78) Position 1 = 32, Position 2 = 44
Branch analysis from position: 32
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 39
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 43
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
Branch analysis from position: 25
Branch analysis from position: 11
filename:       /in/Ger3D
function name:  mergeArray
number of ops:  47
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $keysStats, !3 = $key, !4 = $index, !5 = $keys, !6 = $merged, !7 = $score, !8 = $arrMerged
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    3     2        ASSIGN                                                   !2, <array>
    5     3      > FE_RESET_R                                       $10     !0, ->11
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->11
          5    >   ASSIGN                                                   !4, ~11
    7     6        INIT_ARRAY                                       ~14     !4, 'arr1'
          7        ADD_ARRAY_ELEMENT                                ~14     null, 'arr2'
    6     8        ASSIGN_DIM                                               !2, !3
    7     9        OP_DATA                                                  ~14
    5    10      > JMP                                                      ->4
         11    >   FE_FREE                                                  $10
   12    12      > FE_RESET_R                                       $15     !0, ->25
         13    > > FE_FETCH_R                                       ~16     $15, !3, ->25
         14    >   ASSIGN                                                   !4, ~16
   13    15        FETCH_DIM_R                                      ~18     !5, !3
         16        TYPE_CHECK                                  128  ~19     ~18
         17        BOOL_NOT                                         ~20     ~19
         18      > JMPZ                                                     ~20, ->21
   14    19    >   ASSIGN_DIM                                               !2, !3
   15    20        OP_DATA                                                  <array>
   19    21    >   FETCH_DIM_W                                      $22     !2, !3
         22        ASSIGN_DIM                                               $22, 'arr2'
         23        OP_DATA                                                  !4
   12    24      > JMP                                                      ->13
         25    >   FE_FREE                                                  $15
   22    26        ASSIGN                                                   !6, <array>
   23    27        INIT_FCALL                                               'sort'
         28        SEND_REF                                                 !2
         29        DO_ICALL                                         $25     
         30      > FE_RESET_R                                       $26     $25, ->44
         31    > > FE_FETCH_R                                       ~27     $26, !7, ->44
         32    >   ASSIGN                                                   !3, ~27
   24    33        FETCH_DIM_R                                      ~29     !2, 'arr2'
         34        TYPE_CHECK                                    2          ~29
         35      > JMPZ                                                     ~30, ->39
   25    36    >   ASSIGN_DIM                                               !6
         37        OP_DATA                                                  null
         38      > JMP                                                      ->43
   27    39    >   FETCH_DIM_R                                      ~33     !2, 'arr2'
         40        FETCH_DIM_R                                      ~34     !1, ~33
         41        ASSIGN_DIM                                               !6
         42        OP_DATA                                                  ~34
   23    43    > > JMP                                                      ->31
         44    >   FE_FREE                                                  $26
   31    45      > RETURN                                                   !8
   32    46*     > RETURN                                                   null

End of function mergearray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.34 ms | 1403 KiB | 18 Q