3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [1, 2, 3, 4]; $index = 2; $value = 9; $remains = array_splice($array, max(0, $index - 1)); var_export( array_merge( $array, [$value], $remains ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/RfQ7Q
function name:  (null)
number of ops:  20
compiled vars:  !0 = $array, !1 = $index, !2 = $value, !3 = $remains
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
    4     1        ASSIGN                                                       !1, 2
    5     2        ASSIGN                                                       !2, 9
    6     3        INIT_FCALL                                                   'array_splice'
          4        SEND_REF                                                     !0
          5        SUB                                                  ~7      !1, 1
          6        FRAMELESS_ICALL_2                max                 ~8      0, ~7
          7        SEND_VAL                                                     ~8
          8        DO_ICALL                                             $9      
          9        ASSIGN                                                       !3, $9
    7    10        INIT_FCALL                                                   'var_export'
    8    11        INIT_FCALL                                                   'array_merge'
    9    12        SEND_VAR                                                     !0
   10    13        INIT_ARRAY                                           ~11     !2
         14        SEND_VAL                                                     ~11
   11    15        SEND_VAR                                                     !3
    8    16        DO_ICALL                                             $12     
   11    17        SEND_VAR                                                     $12
    7    18        DO_ICALL                                                     
   13    19      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.98 ms | 1766 KiB | 16 Q