3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class wtf { function array_merge_recursive_distinct() { $arrays = func_get_args(); $base = array_shift($arrays); foreach ($arrays as $array) { reset($base); //important while (list($key, $value) = @each($array)) { if (is_array($value) && @is_array($base[$key])) { $base[$key] = self::array_merge_recursive_distinct($base[$key], $value); } else { $base[$key] = $value; } } } return $base; } } $a = array( "exists" => 1, "doesnotexist" => 1, "arraytest" => array( "exists" => 1, "doesnotexist" => 1 ) ); $b = array( "exists" => 2, "arraytest" => array( "exists" => 2, ) ); $c = wtf::array_merge_recursive_distinct($a, $b); print_r($c);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TWFdk
function name:  (null)
number of ops:  11
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   ASSIGN                                                   !0, <array>
   32     1        ASSIGN                                                   !1, <array>
   39     2        INIT_STATIC_METHOD_CALL                                  'wtf', 'array_merge_recursive_distinct'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   41     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Class wtf:
Function array_merge_recursive_distinct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 41
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 41
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 12
Branch analysis from position: 40
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 12
2 jumps found. (Code = 46) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 40, Position 2 = 12
Branch analysis from position: 40
Branch analysis from position: 12
Branch analysis from position: 19
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
filename:       /in/TWFdk
function name:  array_merge_recursive_distinct
number of ops:  44
compiled vars:  !0 = $arrays, !1 = $base, !2 = $array, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   FUNC_GET_ARGS                                    ~5      
          1        ASSIGN                                                   !0, ~5
    6     2        INIT_FCALL                                               'array_shift'
          3        SEND_REF                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !1, $7
    8     6      > FE_RESET_R                                       $9      !0, ->41
          7    > > FE_FETCH_R                                               $9, !2, ->41
    9     8    >   INIT_FCALL                                               'reset'
          9        SEND_REF                                                 !1
         10        DO_ICALL                                                 
   10    11      > JMP                                                      ->30
   11    12    >   TYPE_CHECK                                  128  ~11     !3
         13      > JMPZ_EX                                          ~11     ~11, ->19
         14    >   BEGIN_SILENCE                                    ~12     
         15        FETCH_DIM_R                                      ~13     !1, !4
         16        TYPE_CHECK                                  128  ~14     ~13
         17        END_SILENCE                                              ~12
         18        BOOL                                             ~11     ~14
         19    > > JMPZ                                                     ~11, ->28
   12    20    >   INIT_STATIC_METHOD_CALL                                  'array_merge_recursive_distinct'
         21        FETCH_DIM_R                                      ~16     !1, !4
         22        SEND_VAL                                                 ~16
         23        SEND_VAR                                                 !3
         24        DO_FCALL                                      0  $17     
         25        ASSIGN_DIM                                               !1, !4
         26        OP_DATA                                                  $17
         27      > JMP                                                      ->30
   14    28    >   ASSIGN_DIM                                               !1, !4
         29        OP_DATA                                                  !3
   10    30    >   BEGIN_SILENCE                                    ~19     
         31        INIT_FCALL_BY_NAME                                       'each'
         32        SEND_VAR_EX                                              !2
         33        DO_FCALL                                      0  $20     
         34        END_SILENCE                                              ~19
         35        FETCH_LIST_R                                     $21     $20, 0
         36        ASSIGN                                                   !4, $21
         37        FETCH_LIST_R                                     $23     $20, 1
         38        ASSIGN                                                   !3, $23
         39      > JMPNZ                                                    $20, ->12
    8    40    > > JMP                                                      ->7
         41    >   FE_FREE                                                  $9
   19    42      > RETURN                                                   !1
   20    43*     > RETURN                                                   null

End of function array_merge_recursive_distinct

End of class wtf.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
181.93 ms | 1400 KiB | 22 Q