3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPairs($data) { shuffle($data); $result = [[$data[0], $data[count($data)-1]]]; for($i=0; $i<count($data)-1; $i++) { $result[] = [$data[$i], $data[$i+1]]; } return $result; } $data = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth']; var_dump(getPairs($data));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ajY2W
function name:  (null)
number of ops:  8
compiled vars:  !0 = $data
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   ASSIGN                                                   !0, <array>
   14     1        INIT_FCALL                                               'var_dump'
          2        INIT_FCALL                                               'getpairs'
          3        SEND_VAR                                                 !0
          4        DO_FCALL                                      0  $2      
          5        SEND_VAR                                                 $2
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function getpairs:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 14
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 14
Branch analysis from position: 26
Branch analysis from position: 14
filename:       /in/ajY2W
function name:  getPairs
number of ops:  28
compiled vars:  !0 = $data, !1 = $result, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'shuffle'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    5     4        FETCH_DIM_R                                      ~4      !0, 0
          5        INIT_ARRAY                                       ~5      ~4
          6        COUNT                                            ~6      !0
          7        SUB                                              ~7      ~6, 1
          8        FETCH_DIM_R                                      ~8      !0, ~7
          9        ADD_ARRAY_ELEMENT                                ~5      ~8
         10        INIT_ARRAY                                       ~9      ~5
         11        ASSIGN                                                   !1, ~9
    6    12        ASSIGN                                                   !2, 0
         13      > JMP                                                      ->22
    8    14    >   FETCH_DIM_R                                      ~13     !0, !2
         15        INIT_ARRAY                                       ~14     ~13
         16        ADD                                              ~15     !2, 1
         17        FETCH_DIM_R                                      ~16     !0, ~15
         18        ADD_ARRAY_ELEMENT                                ~14     ~16
         19        ASSIGN_DIM                                               !1
         20        OP_DATA                                                  ~14
    6    21        PRE_INC                                                  !2
         22    >   COUNT                                            ~18     !0
         23        SUB                                              ~19     ~18, 1
         24        IS_SMALLER                                               !2, ~19
         25      > JMPNZ                                                    ~20, ->14
   10    26    > > RETURN                                                   !1
   11    27*     > RETURN                                                   null

End of function getpairs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.59 ms | 1399 KiB | 18 Q