3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_shift_second(&$array) { $keys = array_keys($array); if (count($keys) < 2) { return false; } $value = $array[$keys[1]]; unset($array[$keys[1]]); return $value; } $a = [1, 2, 3, 4]; var_dump(array_shift_second($a)); var_dump(array_shift_second($a)); var_dump(array_shift_second($a)); var_dump(array_shift_second($a)); var_dump(array_shift_second($a));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1VBnM
function name:  (null)
number of ops:  32
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ASSIGN                                                   !0, <array>
   19     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'array_shift_second'
          3        SEND_REF                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
   20     7        INIT_FCALL                                               'var_dump'
          8        INIT_FCALL                                               'array_shift_second'
          9        SEND_REF                                                 !0
         10        DO_FCALL                                      0  $4      
         11        SEND_VAR                                                 $4
         12        DO_ICALL                                                 
   21    13        INIT_FCALL                                               'var_dump'
         14        INIT_FCALL                                               'array_shift_second'
         15        SEND_REF                                                 !0
         16        DO_FCALL                                      0  $6      
         17        SEND_VAR                                                 $6
         18        DO_ICALL                                                 
   22    19        INIT_FCALL                                               'var_dump'
         20        INIT_FCALL                                               'array_shift_second'
         21        SEND_REF                                                 !0
         22        DO_FCALL                                      0  $8      
         23        SEND_VAR                                                 $8
         24        DO_ICALL                                                 
   23    25        INIT_FCALL                                               'var_dump'
         26        INIT_FCALL                                               'array_shift_second'
         27        SEND_REF                                                 !0
         28        DO_FCALL                                      0  $10     
         29        SEND_VAR                                                 $10
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Function array_shift_second:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 9
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1VBnM
function name:  array_shift_second
number of ops:  16
compiled vars:  !0 = $array, !1 = $keys, !2 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'array_keys'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $3      
          4        ASSIGN                                                   !1, $3
    6     5        COUNT                                            ~5      !1
          6        IS_SMALLER                                               ~5, 2
          7      > JMPZ                                                     ~6, ->9
    7     8    > > RETURN                                                   <false>
   10     9    >   FETCH_DIM_R                                      ~7      !1, 1
         10        FETCH_DIM_R                                      ~8      !0, ~7
         11        ASSIGN                                                   !2, ~8
   12    12        FETCH_DIM_R                                      ~10     !1, 1
         13        UNSET_DIM                                                !0, ~10
   14    14      > RETURN                                                   !2
   15    15*     > RETURN                                                   null

End of function array_shift_second

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.94 ms | 1403 KiB | 22 Q