3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth']; shuffle($data); $result = []; $item = array_shift($data); for($i=0; $i<count($data); $i++) { $result[] = [$item, $item=$data[$i]]; } $result[] = [$result[count($result)-1][1], $result[0][0]]; var_dump($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 11
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 21, Position 2 = 11
Branch analysis from position: 21
Branch analysis from position: 11
filename:       /in/V95L8
function name:  (null)
number of ops:  35
compiled vars:  !0 = $data, !1 = $result, !2 = $item, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        INIT_FCALL                                               'shuffle'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !1, <array>
    6     5        INIT_FCALL                                               'array_shift'
          6        SEND_REF                                                 !0
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !2, $7
    7     9        ASSIGN                                                   !3, 0
         10      > JMP                                                      ->18
    9    11    >   INIT_ARRAY                                       ~11     !2
         12        FETCH_DIM_R                                      ~12     !0, !3
         13        ASSIGN                                           ~13     !2, ~12
         14        ADD_ARRAY_ELEMENT                                ~11     ~13
         15        ASSIGN_DIM                                               !1
         16        OP_DATA                                                  ~11
    7    17        PRE_INC                                                  !3
         18    >   COUNT                                            ~15     !0
         19        IS_SMALLER                                               !3, ~15
         20      > JMPNZ                                                    ~16, ->11
   11    21    >   COUNT                                            ~18     !1
         22        SUB                                              ~19     ~18, 1
         23        FETCH_DIM_R                                      ~20     !1, ~19
         24        FETCH_DIM_R                                      ~21     ~20, 1
         25        INIT_ARRAY                                       ~22     ~21
         26        FETCH_DIM_R                                      ~23     !1, 0
         27        FETCH_DIM_R                                      ~24     ~23, 0
         28        ADD_ARRAY_ELEMENT                                ~22     ~24
         29        ASSIGN_DIM                                               !1
         30        OP_DATA                                                  ~22
   12    31        INIT_FCALL                                               'var_dump'
         32        SEND_VAR                                                 !1
         33        DO_ICALL                                                 
         34      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.03 ms | 1396 KiB | 19 Q