3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('a', 'b', 'c'); $insert_array = array('one' => 'two'); $key = 1; $pos = array_search($key, array_keys($array)) ?: 0; $array = array_slice($array, 0, $pos) + $insert_array + array_slice($array, $pos); var_dump($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/lpFvs
function name:  (null)
number of ops:  29
compiled vars:  !0 = $array, !1 = $insert_array, !2 = $key, !3 = $pos
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, 1
    9     3        INIT_FCALL                                               'array_search'
          4        SEND_VAR                                                 !2
          5        INIT_FCALL                                               'array_keys'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $7      
          8        SEND_VAR                                                 $7
          9        DO_ICALL                                         $8      
         10        JMP_SET                                          ~9      $8, ->12
         11        QM_ASSIGN                                        ~9      0
         12        ASSIGN                                                   !3, ~9
   10    13        INIT_FCALL                                               'array_slice'
         14        SEND_VAR                                                 !0
         15        SEND_VAL                                                 0
         16        SEND_VAR                                                 !3
         17        DO_ICALL                                         $11     
         18        ADD                                              ~12     $11, !1
         19        INIT_FCALL                                               'array_slice'
         20        SEND_VAR                                                 !0
         21        SEND_VAR                                                 !3
         22        DO_ICALL                                         $13     
         23        ADD                                              ~14     ~12, $13
         24        ASSIGN                                                   !0, ~14
   12    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !0
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.31 ms | 1395 KiB | 21 Q