3v4l.org

run code in 300+ PHP versions simultaneously
<?php function arrayMergeRecursive($arraySource, $arrayDestination) { $temp = array(); foreach ($arraySource as $key => $value) { if (is_array($value)) { $associatedDestination = array(); if (isset($arrayDestination[$key])) { $associatedDestination = $arrayDestination[$key]; } $temp[$key] = arrayMergeRecursive($value, $associatedDestination); continue; } if (isset($arrayDestination[$key])) { $temp[$key] = $arrayDestination[$key]; } else { $temp[$key] = $arraySource[$key]; } } return $temp; } $source = ["a" => 1, "b" => 2, "c" => ["x" => 1, "y" => 2]]; $x = ["c" => 1, "d" => 10, "a" => 5]; var_dump(arrayMergeRecursive($source, $x)); var_dump(array_replace_recursive($source, $x));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4Hmlh
function name:  (null)
number of ops:  17
compiled vars:  !0 = $source, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ASSIGN                                                   !0, <array>
   31     1        ASSIGN                                                   !1, <array>
   33     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'arraymergerecursive'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
   35     9        INIT_FCALL                                               'var_dump'
         10        INIT_FCALL                                               'array_replace_recursive'
         11        SEND_VAR                                                 !0
         12        SEND_VAR                                                 !1
         13        DO_ICALL                                         $6      
         14        SEND_VAR                                                 $6
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function arraymergerecursive:
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 = 8, Position 2 = 20
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
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/4Hmlh
function name:  arrayMergeRecursive
number of ops:  33
compiled vars:  !0 = $arraySource, !1 = $arrayDestination, !2 = $temp, !3 = $value, !4 = $key, !5 = $associatedDestination
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ASSIGN                                                   !2, <array>
    5     3      > FE_RESET_R                                       $7      !0, ->30
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->30
          5    >   ASSIGN                                                   !4, ~8
    7     6        TYPE_CHECK                                  128          !3
          7      > JMPZ                                                     ~10, ->20
    9     8    >   ASSIGN                                                   !5, <array>
   10     9        ISSET_ISEMPTY_DIM_OBJ                         0          !1, !4
         10      > JMPZ                                                     ~12, ->13
   11    11    >   FETCH_DIM_R                                      ~13     !1, !4
         12        ASSIGN                                                   !5, ~13
   14    13    >   INIT_FCALL_BY_NAME                                       'arrayMergeRecursive'
         14        SEND_VAR_EX                                              !3
         15        SEND_VAR_EX                                              !5
         16        DO_FCALL                                      0  $16     
         17        ASSIGN_DIM                                               !2, !4
         18        OP_DATA                                                  $16
   16    19      > JMP                                                      ->4
   19    20    >   ISSET_ISEMPTY_DIM_OBJ                         0          !1, !4
         21      > JMPZ                                                     ~17, ->26
   20    22    >   FETCH_DIM_R                                      ~19     !1, !4
         23        ASSIGN_DIM                                               !2, !4
         24        OP_DATA                                                  ~19
         25      > JMP                                                      ->29
   22    26    >   FETCH_DIM_R                                      ~21     !0, !4
         27        ASSIGN_DIM                                               !2, !4
         28        OP_DATA                                                  ~21
    5    29    > > JMP                                                      ->4
         30    >   FE_FREE                                                  $7
   26    31      > RETURN                                                   !2
   27    32*     > RETURN                                                   null

End of function arraymergerecursive

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
167.69 ms | 1402 KiB | 18 Q