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($data));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0qfHK
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_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
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 20
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 20
Branch analysis from position: 31
Branch analysis from position: 20
filename:       /in/0qfHK
function name:  getPairs
number of ops:  33
compiled vars:  !0 = $data, !1 = $end, !2 = $count, !3 = $result, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_DYNAMIC_CALL                                        !2
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0  $5      
          4        ASSIGN                                           ~6      !1, $5
          5        BOOL_NOT                                         ~7      ~6
          6      > JMPZ                                                     ~7, ->8
    6     7    > > RETURN                                                   null
    8     8    >   INIT_FCALL                                               'shuffle'
          9        SEND_REF                                                 !0
         10        DO_ICALL                                                 
    9    11        FETCH_DIM_R                                      ~9      !0, 0
         12        INIT_ARRAY                                       ~10     ~9
         13        SUB                                              ~11     !1, 1
         14        FETCH_DIM_R                                      ~12     !0, ~11
         15        ADD_ARRAY_ELEMENT                                ~10     ~12
         16        INIT_ARRAY                                       ~13     ~10
         17        ASSIGN                                                   !3, ~13
   10    18        ASSIGN                                                   !4, 0
         19      > JMP                                                      ->28
   12    20    >   FETCH_DIM_R                                      ~17     !0, !4
         21        INIT_ARRAY                                       ~18     ~17
         22        ADD                                              ~19     !4, 1
         23        FETCH_DIM_R                                      ~20     !0, ~19
         24        ADD_ARRAY_ELEMENT                                ~18     ~20
         25        ASSIGN_DIM                                               !3
         26        OP_DATA                                                  ~18
   10    27        PRE_INC                                                  !4
         28    >   SUB                                              ~22     !1, 1
         29        IS_SMALLER                                               !4, ~22
         30      > JMPNZ                                                    ~23, ->20
   14    31    > > RETURN                                                   !3
   15    32*     > RETURN                                                   null

End of function getpairs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.08 ms | 1403 KiB | 18 Q