3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array('a' => 2, 'b' => 1, 'c' => 4); $first = array(key($array) => current($array)); // Get the first key/value pair array_shift($array); // Remove it from your array $last = array(end($array) => key($array)); // Get the last key/value pair array_pop($array); // Remove it from the array $array = array_merge($last, $array, $first); // Put it back together print_r($array);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VMQ7n
function name:  (null)
number of ops:  33
compiled vars:  !0 = $array, !1 = $first, !2 = $last
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'key'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $4      
          4        INIT_FCALL                                               'current'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $5      
          7        INIT_ARRAY                                       ~6      $5, $4
          8        ASSIGN                                                   !1, ~6
    5     9        INIT_FCALL                                               'array_shift'
         10        SEND_REF                                                 !0
         11        DO_ICALL                                                 
    7    12        INIT_FCALL                                               'end'
         13        SEND_REF                                                 !0
         14        DO_ICALL                                         $9      
         15        INIT_FCALL                                               'key'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $10     
         18        INIT_ARRAY                                       ~11     $10, $9
         19        ASSIGN                                                   !2, ~11
    8    20        INIT_FCALL                                               'array_pop'
         21        SEND_REF                                                 !0
         22        DO_ICALL                                                 
   10    23        INIT_FCALL                                               'array_merge'
         24        SEND_VAR                                                 !2
         25        SEND_VAR                                                 !0
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $14     
         28        ASSIGN                                                   !0, $14
   12    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !0
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.24 ms | 1396 KiB | 27 Q