3v4l.org

run code in 300+ PHP versions simultaneously
<?php function kv(& $a) { $b = $a; end($a); $kv = [key($a), current($a)]; array_pop($a); return $kv; } $a = [1, 2, 3, 4, 5, 6]; next($a); next($a); echo current($a) . PHP_EOL; var_dump($a); var_dump(kv($a)); echo current($a) . PHP_EOL; var_dump($a);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7bESVL
function name:  (null)
number of ops:  30
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ASSIGN                                                   !0, <array>
   11     1        INIT_FCALL                                               'next'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
          4        INIT_FCALL                                               'next'
          5        SEND_REF                                                 !0
          6        DO_ICALL                                                 
   13     7        INIT_FCALL                                               'current'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $4      
         10        CONCAT                                           ~5      $4, '%0A'
         11        ECHO                                                     ~5
   14    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                                 
   15    15        INIT_FCALL                                               'var_dump'
         16        INIT_FCALL                                               'kv'
         17        SEND_REF                                                 !0
         18        DO_FCALL                                      0  $7      
         19        SEND_VAR                                                 $7
         20        DO_ICALL                                                 
   16    21        INIT_FCALL                                               'current'
         22        SEND_VAR                                                 !0
         23        DO_ICALL                                         $9      
         24        CONCAT                                           ~10     $9, '%0A'
         25        ECHO                                                     ~10
   17    26        INIT_FCALL                                               'var_dump'
         27        SEND_VAR                                                 !0
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Function kv:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7bESVL
function name:  kv
number of ops:  19
compiled vars:  !0 = $a, !1 = $b, !2 = $kv
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        ASSIGN                                                   !1, !0
    4     2        INIT_FCALL                                               'end'
          3        SEND_REF                                                 !0
          4        DO_ICALL                                                 
    5     5        INIT_FCALL                                               'key'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $5      
          8        INIT_ARRAY                                       ~6      $5
          9        INIT_FCALL                                               'current'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $7      
         12        ADD_ARRAY_ELEMENT                                ~6      $7
         13        ASSIGN                                                   !2, ~6
    6    14        INIT_FCALL                                               'array_pop'
         15        SEND_REF                                                 !0
         16        DO_ICALL                                                 
    7    17      > RETURN                                                   !2
    8    18*     > RETURN                                                   null

End of function kv

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.02 ms | 1403 KiB | 26 Q