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_flip(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/6i0rQ
function name:  (null)
number of ops:  36
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                                               'array_flip'
         13        INIT_FCALL                                               'end'
         14        SEND_REF                                                 !0
         15        DO_ICALL                                         $9      
         16        INIT_FCALL                                               'key'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $10     
         19        INIT_ARRAY                                       ~11     $10, $9
         20        SEND_VAL                                                 ~11
         21        DO_ICALL                                         $12     
         22        ASSIGN                                                   !2, $12
    8    23        INIT_FCALL                                               'array_pop'
         24        SEND_REF                                                 !0
         25        DO_ICALL                                                 
   10    26        INIT_FCALL                                               'array_merge'
         27        SEND_VAR                                                 !2
         28        SEND_VAR                                                 !0
         29        SEND_VAR                                                 !1
         30        DO_ICALL                                         $15     
         31        ASSIGN                                                   !0, $15
   12    32        INIT_FCALL                                               'print_r'
         33        SEND_VAR                                                 !0
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.12 ms | 1401 KiB | 29 Q