3v4l.org

run code in 300+ PHP versions simultaneously
<?php function consecutiveCharCount($string) { $lcString = strtolower($string); $prevChar = $lcString[0]; $currentLen = 0; $maxLen = 0; $ascending = null; for ($i = 1; $i < strlen($lcString); $i++) { $diff = ord($lcString[$i]) - ord($prevChar); if ($diff == 1) { if ($ascending !== true) { $ascending = true; $currentLen = 0; } $currentLen += 1; } elseif ($diff == -1) { if ($ascending !== false) { $ascending = false; $currentLen = 0; } $currentLen += 1; } else { $currentLen = 0; } $maxLen = max($maxLen, $currentLen); $prevChar = $lcString[$i]; } return $maxLen; } echo consecutiveCharCount("abcdegionoas"); echo consecutiveCharCount("EDCb00808asabc"); echo consecutiveCharCount("asg7898"); echo consecutiveCharCount("asgab876567asfon");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6At9F
function name:  (null)
number of ops:  17
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   INIT_FCALL                                               'consecutivecharcount'
          1        SEND_VAL                                                 'abcdegionoas'
          2        DO_FCALL                                      0  $0      
          3        ECHO                                                     $0
   34     4        INIT_FCALL                                               'consecutivecharcount'
          5        SEND_VAL                                                 'EDCb00808asabc'
          6        DO_FCALL                                      0  $1      
          7        ECHO                                                     $1
   35     8        INIT_FCALL                                               'consecutivecharcount'
          9        SEND_VAL                                                 'asg7898'
         10        DO_FCALL                                      0  $2      
         11        ECHO                                                     $2
   36    12        INIT_FCALL                                               'consecutivecharcount'
         13        SEND_VAL                                                 'asgab876567asfon'
         14        DO_FCALL                                      0  $3      
         15        ECHO                                                     $3
         16      > RETURN                                                   1

Function consecutivecharcount:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 12
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 27
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 12
Branch analysis from position: 49
Branch analysis from position: 12
Branch analysis from position: 27
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 35
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 35
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 12
Branch analysis from position: 49
Branch analysis from position: 12
filename:       /in/6At9F
function name:  consecutiveCharCount
number of ops:  51
compiled vars:  !0 = $string, !1 = $lcString, !2 = $prevChar, !3 = $currentLen, !4 = $maxLen, !5 = $ascending, !6 = $i, !7 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    4     1        INIT_FCALL                                               'strtolower'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $8      
          4        ASSIGN                                                   !1, $8
    5     5        FETCH_DIM_R                                      ~10     !1, 0
          6        ASSIGN                                                   !2, ~10
    6     7        ASSIGN                                                   !3, 0
    7     8        ASSIGN                                                   !4, 0
    8     9        ASSIGN                                                   !5, null
    9    10        ASSIGN                                                   !6, 1
         11      > JMP                                                      ->46
   10    12    >   INIT_FCALL                                               'ord'
         13        FETCH_DIM_R                                      ~16     !1, !6
         14        SEND_VAL                                                 ~16
         15        DO_ICALL                                         $17     
         16        INIT_FCALL                                               'ord'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                         $18     
         19        SUB                                              ~19     $17, $18
         20        ASSIGN                                                   !7, ~19
   11    21        IS_EQUAL                                                 !7, 1
         22      > JMPZ                                                     ~21, ->29
   12    23    >   TYPE_CHECK                                  1014          !5
         24      > JMPZ                                                     ~22, ->27
   13    25    >   ASSIGN                                                   !5, <true>
   14    26        ASSIGN                                                   !3, 0
   16    27    >   ASSIGN_OP                                     1          !3, 1
         28      > JMP                                                      ->38
   17    29    >   IS_EQUAL                                                 !7, -1
         30      > JMPZ                                                     ~26, ->37
   18    31    >   TYPE_CHECK                                  1018          !5
         32      > JMPZ                                                     ~27, ->35
   19    33    >   ASSIGN                                                   !5, <false>
   20    34        ASSIGN                                                   !3, 0
   22    35    >   ASSIGN_OP                                     1          !3, 1
         36      > JMP                                                      ->38
   24    37    >   ASSIGN                                                   !3, 0
   26    38    >   INIT_FCALL                                               'max'
         39        SEND_VAR                                                 !4
         40        SEND_VAR                                                 !3
         41        DO_ICALL                                         $32     
         42        ASSIGN                                                   !4, $32
   27    43        FETCH_DIM_R                                      ~34     !1, !6
         44        ASSIGN                                                   !2, ~34
    9    45        PRE_INC                                                  !6
         46    >   STRLEN                                           ~37     !1
         47        IS_SMALLER                                               !6, ~37
         48      > JMPNZ                                                    ~38, ->12
   30    49    > > RETURN                                                   !4
   31    50*     > RETURN                                                   null

End of function consecutivecharcount

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.64 ms | 1403 KiB | 23 Q