3v4l.org

run code in 300+ PHP versions simultaneously
<?php function scholar_parse_time($time) { if (preg_match('/^\s*(?P<hour>\d+)(?>:(?P<minute>\d+))(?>:(?P<second>\d+(\.\d*)?))?\s*$/', $time, $match)) { $h = intval($match['hour']); $m = isset($match['minute']) ? intval($match['minute']) : null; $s = isset($match['second']) ? floatval($match['second']) : null; $is = null; if ($h < 24 && (null === $m || $m < 60) && (null === $s || $s < 60)) { if (null !== $s) { $is = intval($s); $ms = $s - $is; } return array( 'hour' => $h, 'minute' => $m, 'second' => $is, 'millis' => round($ms * 1000), 'iso' => null === $m ? sprintf('%02d', $h) : (null === $s ? sprintf('%02d:%02d', $h, $m) : sprintf('%02d:%02d:%02d', $h, $m, $s) ), ); } } return false; } var_dump(scholar_parse_time('0:1')); var_dump(scholar_parse_time('0:1:1')); var_dump(scholar_parse_time('0:1:1.1')); var_dump(scholar_parse_time('0:1:1.'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/mcBN7
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'scholar_parse_time'
          2        SEND_VAL                                                 '0%3A1'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   36     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'scholar_parse_time'
          8        SEND_VAL                                                 '0%3A1%3A1'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   37    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'scholar_parse_time'
         14        SEND_VAL                                                 '0%3A1%3A1.1'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   38    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'scholar_parse_time'
         20        SEND_VAL                                                 '0%3A1%3A1.'
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Function scholar_parse_time:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 82
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
2 jumps found. (Code = 47) Position 1 = 31, Position 2 = 33
Branch analysis from position: 31
2 jumps found. (Code = 46) Position 1 = 35, Position 2 = 40
Branch analysis from position: 35
2 jumps found. (Code = 47) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 82
Branch analysis from position: 41
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 47
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 63
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 80
Branch analysis from position: 80
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 72
Branch analysis from position: 65
1 jumps found. (Code = 42) Position 1 = 79
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 82
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 40
Branch analysis from position: 33
Branch analysis from position: 34
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 29, Position 2 = 34
Branch analysis from position: 29
Branch analysis from position: 34
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 24
Branch analysis from position: 20
Branch analysis from position: 24
Branch analysis from position: 82
filename:       /in/mcBN7
function name:  scholar_parse_time
number of ops:  84
compiled vars:  !0 = $time, !1 = $match, !2 = $h, !3 = $m, !4 = $s, !5 = $is, !6 = $ms
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    5     1        INIT_FCALL                                               'preg_match'
          2        SEND_VAL                                                 '%2F%5E%5Cs%2A%28%3FP%3Chour%3E%5Cd%2B%29%28%3F%3E%3A%28%3FP%3Cminute%3E%5Cd%2B%29%29%28%3F%3E%3A%28%3FP%3Csecond%3E%5Cd%2B%28%5C.%5Cd%2A%29%3F%29%29%3F%5Cs%2A%24%2F'
          3        SEND_VAR                                                 !0
          4        SEND_REF                                                 !1
          5        DO_ICALL                                         $7      
          6      > JMPZ                                                     $7, ->82
    6     7    >   FETCH_DIM_R                                      ~8      !1, 'hour'
          8        CAST                                          4  ~9      ~8
          9        ASSIGN                                                   !2, ~9
    7    10        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'minute'
         11      > JMPZ                                                     ~11, ->16
         12    >   FETCH_DIM_R                                      ~12     !1, 'minute'
         13        CAST                                          4  ~13     ~12
         14        QM_ASSIGN                                        ~14     ~13
         15      > JMP                                                      ->17
         16    >   QM_ASSIGN                                        ~14     null
         17    >   ASSIGN                                                   !3, ~14
    8    18        ISSET_ISEMPTY_DIM_OBJ                         0          !1, 'second'
         19      > JMPZ                                                     ~16, ->24
         20    >   FETCH_DIM_R                                      ~17     !1, 'second'
         21        CAST                                          5  ~18     ~17
         22        QM_ASSIGN                                        ~19     ~18
         23      > JMP                                                      ->25
         24    >   QM_ASSIGN                                        ~19     null
         25    >   ASSIGN                                                   !4, ~19
    9    26        ASSIGN                                                   !5, null
   11    27        IS_SMALLER                                       ~22     !2, 24
         28      > JMPZ_EX                                          ~22     ~22, ->34
         29    >   TYPE_CHECK                                    2  ~23     !3
         30      > JMPNZ_EX                                         ~23     ~23, ->33
         31    >   IS_SMALLER                                       ~24     !3, 60
         32        BOOL                                             ~23     ~24
         33    >   BOOL                                             ~22     ~23
         34    > > JMPZ_EX                                          ~22     ~22, ->40
         35    >   TYPE_CHECK                                    2  ~25     !4
         36      > JMPNZ_EX                                         ~25     ~25, ->39
         37    >   IS_SMALLER                                       ~26     !4, 60
         38        BOOL                                             ~25     ~26
         39    >   BOOL                                             ~22     ~25
         40    > > JMPZ                                                     ~22, ->82
   12    41    >   TYPE_CHECK                                  1020          !4
         42      > JMPZ                                                     ~27, ->47
   13    43    >   CAST                                          4  ~28     !4
         44        ASSIGN                                                   !5, ~28
   14    45        SUB                                              ~30     !4, !5
         46        ASSIGN                                                   !6, ~30
   17    47    >   INIT_ARRAY                                       ~32     !2, 'hour'
   18    48        ADD_ARRAY_ELEMENT                                ~32     !3, 'minute'
   19    49        ADD_ARRAY_ELEMENT                                ~32     !5, 'second'
   20    50        INIT_FCALL                                               'round'
         51        MUL                                              ~33     !6, 1000
         52        SEND_VAL                                                 ~33
         53        DO_ICALL                                         $34     
         54        ADD_ARRAY_ELEMENT                                ~32     $34, 'millis'
   21    55        TYPE_CHECK                                    2          !3
         56      > JMPZ                                                     ~35, ->63
   22    57    >   INIT_FCALL                                               'sprintf'
         58        SEND_VAL                                                 '%2502d'
         59        SEND_VAR                                                 !2
         60        DO_ICALL                                         $36     
         61        QM_ASSIGN                                        ~37     $36
         62      > JMP                                                      ->80
   23    63    >   TYPE_CHECK                                    2          !4
         64      > JMPZ                                                     ~38, ->72
   24    65    >   INIT_FCALL                                               'sprintf'
         66        SEND_VAL                                                 '%2502d%3A%2502d'
         67        SEND_VAR                                                 !2
         68        SEND_VAR                                                 !3
         69        DO_ICALL                                         $39     
         70        QM_ASSIGN                                        ~40     $39
         71      > JMP                                                      ->79
   25    72    >   INIT_FCALL                                               'sprintf'
         73        SEND_VAL                                                 '%2502d%3A%2502d%3A%2502d'
         74        SEND_VAR                                                 !2
         75        SEND_VAR                                                 !3
         76        SEND_VAR                                                 !4
         77        DO_ICALL                                         $41     
         78        QM_ASSIGN                                        ~40     $41
         79    >   QM_ASSIGN                                        ~37     ~40
         80    >   ADD_ARRAY_ELEMENT                                ~32     ~37, 'iso'
         81      > RETURN                                                   ~32
   31    82    > > RETURN                                                   <false>
   32    83*     > RETURN                                                   null

End of function scholar_parse_time

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.02 ms | 1407 KiB | 25 Q