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

End of function scholar_parse_time

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
166.95 ms | 1411 KiB | 25 Q