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; if ($h < 24 && (null === $m || $m < 60) && (null === $s || $s < 60)) { $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/n9TN8
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     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                                                 
   34     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                                                 
   35    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                                                 
   36    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 = 79
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 = 28, Position 2 = 33
Branch analysis from position: 28
2 jumps found. (Code = 47) Position 1 = 30, Position 2 = 32
Branch analysis from position: 30
2 jumps found. (Code = 46) Position 1 = 34, Position 2 = 39
Branch analysis from position: 34
2 jumps found. (Code = 47) Position 1 = 36, Position 2 = 38
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 40, Position 2 = 79
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 60
Branch analysis from position: 54
1 jumps found. (Code = 42) Position 1 = 77
Branch analysis from position: 77
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 60
2 jumps found. (Code = 43) Position 1 = 62, Position 2 = 69
Branch analysis from position: 62
1 jumps found. (Code = 42) Position 1 = 76
Branch analysis from position: 76
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 69
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 79
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
Branch analysis from position: 39
Branch analysis from position: 32
Branch analysis from position: 33
Branch analysis from position: 24
2 jumps found. (Code = 46) Position 1 = 28, Position 2 = 33
Branch analysis from position: 28
Branch analysis from position: 33
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: 79
filename:       /in/n9TN8
function name:  scholar_parse_time
number of ops:  81
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, ->79
    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
   10    26        IS_SMALLER                                       ~21     !2, 24
         27      > JMPZ_EX                                          ~21     ~21, ->33
         28    >   TYPE_CHECK                                    2  ~22     !3
         29      > JMPNZ_EX                                         ~22     ~22, ->32
         30    >   IS_SMALLER                                       ~23     !3, 60
         31        BOOL                                             ~22     ~23
         32    >   BOOL                                             ~21     ~22
         33    > > JMPZ_EX                                          ~21     ~21, ->39
         34    >   TYPE_CHECK                                    2  ~24     !4
         35      > JMPNZ_EX                                         ~24     ~24, ->38
         36    >   IS_SMALLER                                       ~25     !4, 60
         37        BOOL                                             ~24     ~25
         38    >   BOOL                                             ~21     ~24
         39    > > JMPZ                                                     ~21, ->79
   11    40    >   CAST                                          4  ~26     !4
         41        ASSIGN                                                   !5, ~26
   12    42        SUB                                              ~28     !4, !5
         43        ASSIGN                                                   !6, ~28
   15    44        INIT_ARRAY                                       ~30     !2, 'hour'
   16    45        ADD_ARRAY_ELEMENT                                ~30     !3, 'minute'
   17    46        ADD_ARRAY_ELEMENT                                ~30     !5, 'second'
   18    47        INIT_FCALL                                               'round'
         48        MUL                                              ~31     !6, 1000
         49        SEND_VAL                                                 ~31
         50        DO_ICALL                                         $32     
         51        ADD_ARRAY_ELEMENT                                ~30     $32, 'millis'
   19    52        TYPE_CHECK                                    2          !3
         53      > JMPZ                                                     ~33, ->60
   20    54    >   INIT_FCALL                                               'sprintf'
         55        SEND_VAL                                                 '%2502d'
         56        SEND_VAR                                                 !2
         57        DO_ICALL                                         $34     
         58        QM_ASSIGN                                        ~35     $34
         59      > JMP                                                      ->77
   21    60    >   TYPE_CHECK                                    2          !4
         61      > JMPZ                                                     ~36, ->69
   22    62    >   INIT_FCALL                                               'sprintf'
         63        SEND_VAL                                                 '%2502d%3A%2502d'
         64        SEND_VAR                                                 !2
         65        SEND_VAR                                                 !3
         66        DO_ICALL                                         $37     
         67        QM_ASSIGN                                        ~38     $37
         68      > JMP                                                      ->76
   23    69    >   INIT_FCALL                                               'sprintf'
         70        SEND_VAL                                                 '%2502d%3A%2502d%3A%2502d'
         71        SEND_VAR                                                 !2
         72        SEND_VAR                                                 !3
         73        SEND_VAR                                                 !4
         74        DO_ICALL                                         $39     
         75        QM_ASSIGN                                        ~38     $39
         76    >   QM_ASSIGN                                        ~35     ~38
         77    >   ADD_ARRAY_ELEMENT                                ~30     ~35, 'iso'
         78      > RETURN                                                   ~30
   29    79    > > RETURN                                                   <false>
   30    80*     > RETURN                                                   null

End of function scholar_parse_time

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.32 ms | 1411 KiB | 25 Q