3v4l.org

run code in 500+ 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 end($array); $last = array(key($array) => current($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/r87qD
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                                                   'end'
         13        SEND_REF                                                     !0
         14        DO_ICALL                                                     
    8    15        INIT_FCALL                                                   'key'
         16        SEND_VAR                                                     !0
         17        DO_ICALL                                             $10     
         18        INIT_FCALL                                                   'current'
         19        SEND_VAR                                                     !0
         20        DO_ICALL                                             $11     
         21        INIT_ARRAY                                           ~12     $11, $10
         22        ASSIGN                                                       !2, ~12
    9    23        INIT_FCALL                                                   'array_pop'
         24        SEND_REF                                                     !0
         25        DO_ICALL                                                     
   11    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
   13    32        INIT_FCALL                                                   'print_r'
         33        SEND_VAR                                                     !0
         34        DO_ICALL                                                     
         35      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
216.1 ms | 3292 KiB | 20 Q