3v4l.org

run code in 300+ PHP versions simultaneously
<?php function straight($hand) { sort($hand); for ($i = 0; $i <= count($hand) - 5; $i++) { $subhand = array_slice($hand, $i, 5); if ($subhand == range($subhand[0], $subhand[count($subhand)-1])) { echo implode(',' , $hand) . " => straight\n"; break; } } } straight(array(2, 3, 5, 7, 12, 7, 4)); straight(array(2, 3, 5, 6, 12, 7, 4)); straight(array(7, 8, 9, 10, 11, 11, 11)); straight(array(2, 4, 5, 6, 14, 10, 9)); straight(array(2, 3, 5, 7, 7, 4)); straight(array(3, 5, 6, 12, 7, 4)); straight(array(7, 8, 9, 10, 11)); straight(array(2, 4, 5, 6, 3));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SeFSo
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'straight'
          1        SEND_VAL                                                 <array>
          2        DO_FCALL                                      0          
   14     3        INIT_FCALL                                               'straight'
          4        SEND_VAL                                                 <array>
          5        DO_FCALL                                      0          
   15     6        INIT_FCALL                                               'straight'
          7        SEND_VAL                                                 <array>
          8        DO_FCALL                                      0          
   16     9        INIT_FCALL                                               'straight'
         10        SEND_VAL                                                 <array>
         11        DO_FCALL                                      0          
   17    12        INIT_FCALL                                               'straight'
         13        SEND_VAL                                                 <array>
         14        DO_FCALL                                      0          
   18    15        INIT_FCALL                                               'straight'
         16        SEND_VAL                                                 <array>
         17        DO_FCALL                                      0          
   19    18        INIT_FCALL                                               'straight'
         19        SEND_VAL                                                 <array>
         20        DO_FCALL                                      0          
   20    21        INIT_FCALL                                               'straight'
         22        SEND_VAL                                                 <array>
         23        DO_FCALL                                      0          
         24      > RETURN                                                   1

Function straight:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 30
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 6
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 29
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 34, Position 2 = 6
Branch analysis from position: 34
Branch analysis from position: 6
filename:       /in/SeFSo
function name:  straight
number of ops:  35
compiled vars:  !0 = $hand, !1 = $i, !2 = $subhand
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'sort'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
    5     4        ASSIGN                                                   !1, 0
          5      > JMP                                                      ->30
    6     6    >   INIT_FCALL                                               'array_slice'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !1
          9        SEND_VAL                                                 5
         10        DO_ICALL                                         $5      
         11        ASSIGN                                                   !2, $5
    7    12        INIT_FCALL                                               'range'
         13        FETCH_DIM_R                                      ~7      !2, 0
         14        SEND_VAL                                                 ~7
         15        COUNT                                            ~8      !2
         16        SUB                                              ~9      ~8, 1
         17        FETCH_DIM_R                                      ~10     !2, ~9
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                         $11     
         20        IS_EQUAL                                                 !2, $11
         21      > JMPZ                                                     ~12, ->29
    8    22    >   INIT_FCALL                                               'implode'
         23        SEND_VAL                                                 '%2C'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $13     
         26        CONCAT                                           ~14     $13, '+%3D%3E+straight%0A'
         27        ECHO                                                     ~14
    9    28      > JMP                                                      ->34
    5    29    >   PRE_INC                                                  !1
         30    >   COUNT                                            ~16     !0
         31        SUB                                              ~17     ~16, 5
         32        IS_SMALLER_OR_EQUAL                                      !1, ~17
         33      > JMPNZ                                                    ~18, ->6
   12    34    > > RETURN                                                   null

End of function straight

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.59 ms | 1008 KiB | 25 Q