3v4l.org

run code in 300+ PHP versions simultaneously
<?php $prvi = [ 'jabolka' => 'Jabolka', 'hruske' => 'Hruške' ]; $drugi = [ 'borovnice' => 'Borovnice', 'pomarance' => 'Pomaranče' ]; array_splice_preserve_keys( $prvi, 1, null, $drugi ); echo '<pre>'.print_r($prvi, true).'</pre>'; function array_splice_preserve_keys(&$input, $offset, $length=null, $replacement=array()) { if (empty($replacement)) { return array_splice($input, $offset, $length); } $part_before = array_slice($input, 0, $offset, $preserve_keys=true); $part_removed = array_slice($input, $offset, $length, $preserve_keys=true); $part_after = array_slice($input, $offset+$length, null, $preserve_keys=true); $input = $part_before + $replacement + $part_after; return $part_removed; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6uUhl
function name:  (null)
number of ops:  16
compiled vars:  !0 = $prvi, !1 = $drugi
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   13     2        INIT_FCALL_BY_NAME                                       'array_splice_preserve_keys'
          3        SEND_VAR_EX                                              !0
          4        SEND_VAL_EX                                              1
          5        SEND_VAL_EX                                              null
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
   15     8        INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !0
         10        SEND_VAL                                                 <true>
         11        DO_ICALL                                         $5      
         12        CONCAT                                           ~6      '%3Cpre%3E', $5
         13        CONCAT                                           ~7      ~6, '%3C%2Fpre%3E'
         14        ECHO                                                     ~7
   30    15      > RETURN                                                   1

Function array_splice_preserve_keys:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6uUhl
function name:  array_splice_preserve_keys
number of ops:  42
compiled vars:  !0 = $input, !1 = $offset, !2 = $length, !3 = $replacement, !4 = $part_before, !5 = $preserve_keys, !6 = $part_removed, !7 = $part_after
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      <array>
   19     4        ISSET_ISEMPTY_CV                                         !3
          5      > JMPZ                                                     ~8, ->12
   20     6    >   INIT_FCALL                                               'array_splice'
          7        SEND_REF                                                 !0
          8        SEND_VAR                                                 !1
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $9      
         11      > RETURN                                                   $9
   23    12    >   INIT_FCALL                                               'array_slice'
         13        SEND_VAR                                                 !0
         14        SEND_VAL                                                 0
         15        SEND_VAR                                                 !1
         16        ASSIGN                                           ~10     !5, <true>
         17        SEND_VAL                                                 ~10
         18        DO_ICALL                                         $11     
         19        ASSIGN                                                   !4, $11
   24    20        INIT_FCALL                                               'array_slice'
         21        SEND_VAR                                                 !0
         22        SEND_VAR                                                 !1
         23        SEND_VAR                                                 !2
         24        ASSIGN                                           ~13     !5, <true>
         25        SEND_VAL                                                 ~13
         26        DO_ICALL                                         $14     
         27        ASSIGN                                                   !6, $14
   25    28        INIT_FCALL                                               'array_slice'
         29        SEND_VAR                                                 !0
         30        ADD                                              ~16     !1, !2
         31        SEND_VAL                                                 ~16
         32        SEND_VAL                                                 null
         33        ASSIGN                                           ~17     !5, <true>
         34        SEND_VAL                                                 ~17
         35        DO_ICALL                                         $18     
         36        ASSIGN                                                   !7, $18
   27    37        ADD                                              ~20     !4, !3
         38        ADD                                              ~21     ~20, !7
         39        ASSIGN                                                   !0, ~21
   29    40      > RETURN                                                   !6
   30    41*     > RETURN                                                   null

End of function array_splice_preserve_keys

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.02 ms | 1400 KiB | 19 Q