3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = array( 'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 'j', 'k' => 'l', ); $replacement = array( 'w' => 'x', 'y' => 'z' ); $offset = -3; // illegal offset - MAGIC? $length = 2; if ($replacement === null) { // + operator with null causes FATAL ERROR! $replacement = array(); } if (empty($input)) { $input = $replacement; return; } // split array at $offset and prevent keys (4th argument) $beforeItems = array_slice($input, 0, $offset, true); $afterItems = array_slice($input, $offset, null, true); if ($length !== null) { $length = (int)$length; // remove items while ($length > 0) { array_shift($afterItems); $length--; } } $input = $beforeItems + $replacement + $afterItems; print_r($input);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 7
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 36
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 30
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 36, Position 2 = 30
Branch analysis from position: 36
Branch analysis from position: 30
Branch analysis from position: 36
Branch analysis from position: 7
filename:       /in/PO7nL
function name:  (null)
number of ops:  43
compiled vars:  !0 = $input, !1 = $replacement, !2 = $offset, !3 = $length, !4 = $beforeItems, !5 = $afterItems
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   14     2        ASSIGN                                                   !2, -3
   15     3        ASSIGN                                                   !3, 2
   17     4        TYPE_CHECK                                    2          !1
          5      > JMPZ                                                     ~10, ->7
   19     6    >   ASSIGN                                                   !1, <array>
   22     7    >   ISSET_ISEMPTY_CV                                         !0
          8      > JMPZ                                                     ~12, ->11
   23     9    >   ASSIGN                                                   !0, !1
   24    10      > RETURN                                                   null
   28    11    >   INIT_FCALL                                               'array_slice'
         12        SEND_VAR                                                 !0
         13        SEND_VAL                                                 0
         14        SEND_VAR                                                 !2
         15        SEND_VAL                                                 <true>
         16        DO_ICALL                                         $14     
         17        ASSIGN                                                   !4, $14
   29    18        INIT_FCALL                                               'array_slice'
         19        SEND_VAR                                                 !0
         20        SEND_VAR                                                 !2
         21        SEND_VAL                                                 null
         22        SEND_VAL                                                 <true>
         23        DO_ICALL                                         $16     
         24        ASSIGN                                                   !5, $16
   31    25        TYPE_CHECK                                  1020          !3
         26      > JMPZ                                                     ~18, ->36
   32    27    >   CAST                                          4  ~19     !3
         28        ASSIGN                                                   !3, ~19
   34    29      > JMP                                                      ->34
   35    30    >   INIT_FCALL                                               'array_shift'
         31        SEND_REF                                                 !5
         32        DO_ICALL                                                 
   36    33        PRE_DEC                                                  !3
   34    34    >   IS_SMALLER                                               0, !3
         35      > JMPNZ                                                    ~23, ->30
   40    36    >   ADD                                              ~24     !4, !1
         37        ADD                                              ~25     ~24, !5
         38        ASSIGN                                                   !0, ~25
   42    39        INIT_FCALL                                               'print_r'
         40        SEND_VAR                                                 !0
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.35 ms | 1400 KiB | 19 Q