3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRoundedCutoff ($t) { list($hour, $min, $sec) = explode(':', $t); $rmin = $min % 15; $dt = new DateTime( $t ); if ( $sec > 30 ) { $dt = $dt->add(new DateInterval('PT'.(60-$sec).'M')); } else { $dt = $dt->sub(new DateInterval('PT'.$sec.'M')); } if ( $rmin > 7 ) { $dt = $dt->add(new DateInterval('PT'.(15-$rmin).'M')); } else { $dt = $dt->sub(new DateInterval('PT'.$rmin.'M')); } return $dt->format('H:i:s'); } $times = array( '10:52:00', '10:52:59', '10:53:00', '10:50:00', '10:50:14', '10:50:59', '10:50:45', '01:12:00', '01:05:00', '01:58:00', '01:58:59', '01:59:59', '01:01:00', ); foreach ($times as $time) { var_dump($time.' -> '.getRoundedCutoff($time)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 12
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 12
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/jFoTQ
function name:  (null)
number of ops:  14
compiled vars:  !0 = $times, !1 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   ASSIGN                                                   !0, <array>
   38     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   39     3    >   INIT_FCALL                                               'var_dump'
          4        CONCAT                                           ~4      !1, '+-%3E+'
          5        INIT_FCALL                                               'getroundedcutoff'
          6        SEND_VAR                                                 !1
          7        DO_FCALL                                      0  $5      
          8        CONCAT                                           ~6      ~4, $5
          9        SEND_VAL                                                 ~6
         10        DO_ICALL                                                 
   38    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   40    13      > RETURN                                                   1

Function getroundedcutoff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 31
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 53
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 62
Branch analysis from position: 62
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 53
Branch analysis from position: 42
Branch analysis from position: 53
filename:       /in/jFoTQ
function name:  getRoundedCutoff
number of ops:  67
compiled vars:  !0 = $t, !1 = $hour, !2 = $min, !3 = $sec, !4 = $rmin, !5 = $dt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '%3A'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $6      
          5        FETCH_LIST_R                                     $7      $6, 0
          6        ASSIGN                                                   !1, $7
          7        FETCH_LIST_R                                     $9      $6, 1
          8        ASSIGN                                                   !2, $9
          9        FETCH_LIST_R                                     $11     $6, 2
         10        ASSIGN                                                   !3, $11
         11        FREE                                                     $6
    4    12        MOD                                              ~13     !2, 15
         13        ASSIGN                                                   !4, ~13
    5    14        NEW                                              $15     'DateTime'
         15        SEND_VAR_EX                                              !0
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !5, $15
    7    18        IS_SMALLER                                               30, !3
         19      > JMPZ                                                     ~18, ->31
    8    20    >   INIT_METHOD_CALL                                         !5, 'add'
         21        NEW                                              $19     'DateInterval'
         22        SUB                                              ~20     60, !3
         23        CONCAT                                           ~21     'PT', ~20
         24        CONCAT                                           ~22     ~21, 'M'
         25        SEND_VAL_EX                                              ~22
         26        DO_FCALL                                      0          
         27        SEND_VAR_NO_REF_EX                                       $19
         28        DO_FCALL                                      0  $24     
         29        ASSIGN                                                   !5, $24
         30      > JMP                                                      ->40
   10    31    >   INIT_METHOD_CALL                                         !5, 'sub'
         32        NEW                                              $26     'DateInterval'
         33        CONCAT                                           ~27     'PT', !3
         34        CONCAT                                           ~28     ~27, 'M'
         35        SEND_VAL_EX                                              ~28
         36        DO_FCALL                                      0          
         37        SEND_VAR_NO_REF_EX                                       $26
         38        DO_FCALL                                      0  $30     
         39        ASSIGN                                                   !5, $30
   13    40    >   IS_SMALLER                                               7, !4
         41      > JMPZ                                                     ~32, ->53
   14    42    >   INIT_METHOD_CALL                                         !5, 'add'
         43        NEW                                              $33     'DateInterval'
         44        SUB                                              ~34     15, !4
         45        CONCAT                                           ~35     'PT', ~34
         46        CONCAT                                           ~36     ~35, 'M'
         47        SEND_VAL_EX                                              ~36
         48        DO_FCALL                                      0          
         49        SEND_VAR_NO_REF_EX                                       $33
         50        DO_FCALL                                      0  $38     
         51        ASSIGN                                                   !5, $38
         52      > JMP                                                      ->62
   16    53    >   INIT_METHOD_CALL                                         !5, 'sub'
         54        NEW                                              $40     'DateInterval'
         55        CONCAT                                           ~41     'PT', !4
         56        CONCAT                                           ~42     ~41, 'M'
         57        SEND_VAL_EX                                              ~42
         58        DO_FCALL                                      0          
         59        SEND_VAR_NO_REF_EX                                       $40
         60        DO_FCALL                                      0  $44     
         61        ASSIGN                                                   !5, $44
   19    62    >   INIT_METHOD_CALL                                         !5, 'format'
         63        SEND_VAL_EX                                              'H%3Ai%3As'
         64        DO_FCALL                                      0  $46     
         65      > RETURN                                                   $46
   20    66*     > RETURN                                                   null

End of function getroundedcutoff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.35 ms | 1398 KiB | 18 Q