3v4l.org

run code in 300+ PHP versions simultaneously
<?php function extend($base, $replacements) { $base = !is_array($base) ? array() : $base; $replacements = !is_array($replacements) ? array() : $replacements; $ret = array(); foreach ($base as $key => $val) { if (is_int($key)) { // value without key $ret[$val] = null; } else { $ret[$key] = $val; } } return array_replace_recursive($ret, $replacements); } var_dump(extend(array('foo' => 'bar'), array('bar' => 'baz'))); var_dump(extend(array('foo' => 'bar'), array('foo' => 'foo'))); var_dump(extend(array('bar' => 'baz'), array('bar' => 'bar'))); var_dump(extend(array('bar' => 'baz'))); var_dump(extend(array('bar' => 'baz')));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/JHEUh
function name:  (null)
number of ops:  34
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'extend'
          2        SEND_VAL                                                 <array>
          3        SEND_VAL                                                 <array>
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   20     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'extend'
          9        SEND_VAL                                                 <array>
         10        SEND_VAL                                                 <array>
         11        DO_FCALL                                      0  $2      
         12        SEND_VAR                                                 $2
         13        DO_ICALL                                                 
   21    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'extend'
         16        SEND_VAL                                                 <array>
         17        SEND_VAL                                                 <array>
         18        DO_FCALL                                      0  $4      
         19        SEND_VAR                                                 $4
         20        DO_ICALL                                                 
   22    21        INIT_FCALL                                               'var_dump'
         22        INIT_FCALL                                               'extend'
         23        SEND_VAL                                                 <array>
         24        DO_FCALL                                      0  $6      
         25        SEND_VAR                                                 $6
         26        DO_ICALL                                                 
   23    27        INIT_FCALL                                               'var_dump'
         28        INIT_FCALL                                               'extend'
         29        SEND_VAL                                                 <array>
         30        DO_FCALL                                      0  $8      
         31        SEND_VAR                                                 $8
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Function extend:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
2 jumps found. (Code = 78) Position 1 = 19, Position 2 = 28
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 25
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 18, Position 2 = 28
Branch analysis from position: 18
Branch analysis from position: 28
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 14
Branch analysis from position: 12
Branch analysis from position: 14
filename:       /in/JHEUh
function name:  extend
number of ops:  35
compiled vars:  !0 = $base, !1 = $replacements, !2 = $ret, !3 = $val, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        TYPE_CHECK                                  128  ~5      !0
          3        BOOL_NOT                                         ~6      ~5
          4      > JMPZ                                                     ~6, ->7
          5    >   QM_ASSIGN                                        ~7      <array>
          6      > JMP                                                      ->8
          7    >   QM_ASSIGN                                        ~7      !0
          8    >   ASSIGN                                                   !0, ~7
    5     9        TYPE_CHECK                                  128  ~9      !1
         10        BOOL_NOT                                         ~10     ~9
         11      > JMPZ                                                     ~10, ->14
         12    >   QM_ASSIGN                                        ~11     <array>
         13      > JMP                                                      ->15
         14    >   QM_ASSIGN                                        ~11     !1
         15    >   ASSIGN                                                   !1, ~11
    7    16        ASSIGN                                                   !2, <array>
    8    17      > FE_RESET_R                                       $14     !0, ->28
         18    > > FE_FETCH_R                                       ~15     $14, !3, ->28
         19    >   ASSIGN                                                   !4, ~15
    9    20        TYPE_CHECK                                   16          !4
         21      > JMPZ                                                     ~17, ->25
   10    22    >   ASSIGN_DIM                                               !2, !3
         23        OP_DATA                                                  null
         24      > JMP                                                      ->27
   12    25    >   ASSIGN_DIM                                               !2, !4
         26        OP_DATA                                                  !3
    8    27    > > JMP                                                      ->18
         28    >   FE_FREE                                                  $14
   16    29        INIT_FCALL                                               'array_replace_recursive'
         30        SEND_VAR                                                 !2
         31        SEND_VAR                                                 !1
         32        DO_ICALL                                         $20     
         33      > RETURN                                                   $20
   17    34*     > RETURN                                                   null

End of function extend

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.56 ms | 1403 KiB | 22 Q