3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['p' => ['id' => TRUE]]; $b = ['p' => FALSE]; print "Behaves as expected.\n"; var_dump(array_merge_recursive($a, $b)); print "\n\nOMG internal array pointer shenanigans can affect the results of array_merge_recursive()!\n"; $a['p'][0] = 'SOMETHING, anything!'; unset($a['p'][0]); var_dump(array_merge_recursive($a, $b)); print "\n\nThis keeps happening…\n"; var_dump(array_merge_recursive($a, $b)); print "\n\n… not even resetting the internal array pointer helps …\n"; reset($a['p']); var_dump(array_merge_recursive($a, $b)); print "\n\n… nor casting to object, cloning, then back to array …\n"; $a['p'] = (array) clone (object) $a['p']; var_dump(array_merge_recursive($a, $b)); print "\n\n… only forcefully recreating a copy-by-value of the array by using array_slice().\n"; $a['p'] = array_slice($a['p'], 0); var_dump(array_merge_recursive($a, $b));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/fXXsn
function name:  (null)
number of ops:  73
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        ECHO                                                     'Behaves+as+expected.%0A'
    7     3        INIT_FCALL                                               'var_dump'
          4        INIT_FCALL                                               'array_merge_recursive'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
    9    10        ECHO                                                     '%0A%0AOMG+internal+array+pointer+shenanigans+can+affect+the+results+of+array_merge_recursive%28%29%21%0A'
   10    11        FETCH_DIM_W                                      $6      !0, 'p'
         12        ASSIGN_DIM                                               $6, 0
         13        OP_DATA                                                  'SOMETHING%2C+anything%21'
   11    14        FETCH_DIM_UNSET                                  $8      !0, 'p'
         15        UNSET_DIM                                                $8, 0
   12    16        INIT_FCALL                                               'var_dump'
         17        INIT_FCALL                                               'array_merge_recursive'
         18        SEND_VAR                                                 !0
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $9      
         21        SEND_VAR                                                 $9
         22        DO_ICALL                                                 
   14    23        ECHO                                                     '%0A%0AThis+keeps+happening%E2%80%A6%0A'
   15    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'array_merge_recursive'
         26        SEND_VAR                                                 !0
         27        SEND_VAR                                                 !1
         28        DO_ICALL                                         $11     
         29        SEND_VAR                                                 $11
         30        DO_ICALL                                                 
   17    31        ECHO                                                     '%0A%0A%E2%80%A6+not+even+resetting+the+internal+array+pointer+helps+%E2%80%A6%0A'
   18    32        INIT_FCALL                                               'reset'
         33        FETCH_DIM_W                                      $13     !0, 'p'
         34        SEND_REF                                                 $13
         35        DO_ICALL                                                 
   19    36        INIT_FCALL                                               'var_dump'
         37        INIT_FCALL                                               'array_merge_recursive'
         38        SEND_VAR                                                 !0
         39        SEND_VAR                                                 !1
         40        DO_ICALL                                         $15     
         41        SEND_VAR                                                 $15
         42        DO_ICALL                                                 
   21    43        ECHO                                                     '%0A%0A%E2%80%A6+nor+casting+to+object%2C+cloning%2C+then+back+to+array+%E2%80%A6%0A'
   22    44        FETCH_DIM_R                                      ~18     !0, 'p'
         45        CAST                                          8  ~19     ~18
         46        CLONE                                            ~20     ~19
         47        CAST                                          7  ~21     ~20
         48        ASSIGN_DIM                                               !0, 'p'
         49        OP_DATA                                                  ~21
   23    50        INIT_FCALL                                               'var_dump'
         51        INIT_FCALL                                               'array_merge_recursive'
         52        SEND_VAR                                                 !0
         53        SEND_VAR                                                 !1
         54        DO_ICALL                                         $22     
         55        SEND_VAR                                                 $22
         56        DO_ICALL                                                 
   26    57        ECHO                                                     '%0A%0A%E2%80%A6+only+forcefully+recreating+a+copy-by-value+of+the+array+by+using+array_slice%28%29.%0A'
   27    58        INIT_FCALL                                               'array_slice'
         59        FETCH_DIM_R                                      ~25     !0, 'p'
         60        SEND_VAL                                                 ~25
         61        SEND_VAL                                                 0
         62        DO_ICALL                                         $26     
         63        ASSIGN_DIM                                               !0, 'p'
         64        OP_DATA                                                  $26
   28    65        INIT_FCALL                                               'var_dump'
         66        INIT_FCALL                                               'array_merge_recursive'
         67        SEND_VAR                                                 !0
         68        SEND_VAR                                                 !1
         69        DO_ICALL                                         $27     
         70        SEND_VAR                                                 $27
         71        DO_ICALL                                                 
         72      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.26 ms | 1018 KiB | 17 Q