3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getRoundedCutoff ($t) { $dt = new DateTime( $t ); $sec = intval($dt->format('s')); $msec = ( $sec > 30 ) ? '+'.(60-$sec) : '-'.$sec; $dt->modify($msec.' seconds'); $rmin = intval($dt->format('i')) % 15; $mmin = ( $rmin > 7 ) ? '+'.(15-$rmin) : '-'.$rmin; $dt->modify($mmin.' minutes'); 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/Ql4vf
function name:  (null)
number of ops:  14
compiled vars:  !0 = $times, !1 = $time
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ASSIGN                                                   !0, <array>
   31     1      > FE_RESET_R                                       $3      !0, ->12
          2    > > FE_FETCH_R                                               $3, !1, ->12
   32     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                                                 
   31    11      > JMP                                                      ->2
         12    >   FE_FREE                                                  $3
   33    13      > RETURN                                                   1

Function getroundedcutoff:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 16
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 35
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 35
Branch analysis from position: 31
Branch analysis from position: 35
filename:       /in/Ql4vf
function name:  getRoundedCutoff
number of ops:  47
compiled vars:  !0 = $t, !1 = $dt, !2 = $sec, !3 = $msec, !4 = $rmin, !5 = $mmin
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        NEW                                              $6      'DateTime'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $6
    4     5        INIT_METHOD_CALL                                         !1, 'format'
          6        SEND_VAL_EX                                              's'
          7        DO_FCALL                                      0  $9      
          8        CAST                                          4  ~10     $9
          9        ASSIGN                                                   !2, ~10
    5    10        IS_SMALLER                                               30, !2
         11      > JMPZ                                                     ~12, ->16
         12    >   SUB                                              ~13     60, !2
         13        CONCAT                                           ~14     '%2B', ~13
         14        QM_ASSIGN                                        ~15     ~14
         15      > JMP                                                      ->18
         16    >   CONCAT                                           ~16     '-', !2
         17        QM_ASSIGN                                        ~15     ~16
         18    >   ASSIGN                                                   !3, ~15
    6    19        INIT_METHOD_CALL                                         !1, 'modify'
         20        CONCAT                                           ~18     !3, '+seconds'
         21        SEND_VAL_EX                                              ~18
         22        DO_FCALL                                      0          
    8    23        INIT_METHOD_CALL                                         !1, 'format'
         24        SEND_VAL_EX                                              'i'
         25        DO_FCALL                                      0  $20     
         26        CAST                                          4  ~21     $20
         27        MOD                                              ~22     ~21, 15
         28        ASSIGN                                                   !4, ~22
    9    29        IS_SMALLER                                               7, !4
         30      > JMPZ                                                     ~24, ->35
         31    >   SUB                                              ~25     15, !4
         32        CONCAT                                           ~26     '%2B', ~25
         33        QM_ASSIGN                                        ~27     ~26
         34      > JMP                                                      ->37
         35    >   CONCAT                                           ~28     '-', !4
         36        QM_ASSIGN                                        ~27     ~28
         37    >   ASSIGN                                                   !5, ~27
   10    38        INIT_METHOD_CALL                                         !1, 'modify'
         39        CONCAT                                           ~30     !5, '+minutes'
         40        SEND_VAL_EX                                              ~30
         41        DO_FCALL                                      0          
   12    42        INIT_METHOD_CALL                                         !1, 'format'
         43        SEND_VAL_EX                                              'H%3Ai%3As'
         44        DO_FCALL                                      0  $32     
         45      > RETURN                                                   $32
   13    46*     > RETURN                                                   null

End of function getroundedcutoff

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.17 ms | 1403 KiB | 16 Q