3v4l.org

run code in 300+ PHP versions simultaneously
<?php function scholar_parse_time($time) // {{{ { '/^\s*(?P<hour>\d+)(?>:(?P<minute>\d+))?(?>:(?P<second>\d+(\.\d*)?))?\s*$/'; if (preg_match('/^\s*(?>(?P<hour>\d+)(?>:(?P<minute>\d+)(?>:(?P<second>\d+)(?P<millis>\.\d*)?)?)?)\s*$/', $time, $match)) { $h = intval($match['hour']); $m = isset($match['minute']) ? intval($match['minute']) : null; $s = isset($match['second']) ? intval($match['second']) : null; $ms = isset($match['millis']) ? round(floatval($match['millis']) * 1000) : null; if ($h < 24 && (null === $m || $m < 60) && (null === $s || $s < 60)) { return array( 'hour' => $h, 'minute' => $m, 'second' => $s, 'millis' => $ms, '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('19')); var_dump(scholar_parse_time('19:01')); var_dump(scholar_parse_time('19:01:04')); var_dump(scholar_parse_time('19:01:32.')); var_dump(scholar_parse_time('19:01:32.3')); var_dump(scholar_parse_time('19:01.1'));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/848Om
function name:  (null)
number of ops:  37
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'scholar_parse_time'
          2        SEND_VAL                                                 '19'
          3        DO_FCALL                                      0  $0      
          4        SEND_VAR                                                 $0
          5        DO_ICALL                                                 
   32     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'scholar_parse_time'
          8        SEND_VAL                                                 '19%3A01'
          9        DO_FCALL                                      0  $2      
         10        SEND_VAR                                                 $2
         11        DO_ICALL                                                 
   33    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL                                               'scholar_parse_time'
         14        SEND_VAL                                                 '19%3A01%3A04'
         15        DO_FCALL                                      0  $4      
         16        SEND_VAR                                                 $4
         17        DO_ICALL                                                 
   34    18        INIT_FCALL                                               'var_dump'
         19        INIT_FCALL                                               'scholar_parse_time'
         20        SEND_VAL                                                 '19%3A01%3A32.'
         21        DO_FCALL                                      0  $6      
         22        SEND_VAR                                                 $6
         23        DO_ICALL                                                 
   35    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               'scholar_parse_time'
         26        SEND_VAL                                                 '19%3A01%3A32.3'
         27        DO_FCALL                                      0  $8      
         28        SEND_VAR                                                 $8
         29        DO_ICALL                                                 
   36    30        INIT_FCALL                                               'var_dump'
         31        INIT_FCALL                                               'scholar_parse_time'
         32        SEND_VAL                                                 '19%3A01.1'
         33        DO_FCALL                                      0  $10     
         34        SEND_VAR                                                 $10
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

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

End of function scholar_parse_time

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.62 ms | 1411 KiB | 27 Q