3v4l.org

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

End of function getpairs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.07 ms | 1402 KiB | 18 Q