3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr=array("2018-06-27 20:30:20","2018-06-27 20:31:20","2018-06-27 20:37:20","2018-06-27 20:45:20","2018-06-27 20:48:20"); function roundToNearestMinuteInterval($time, $interval) { $timestamp = strtotime($time); $rounded = round($timestamp / ($interval * 60), 0) * $interval * 60; return $rounded; } $interval = 5; // minutes $start = roundToNearestMinuteInterval(min($arr), $interval); $end = roundToNearestMinuteInterval(max($arr), $interval); for (; $start <= $end; $start += $interval * 60) { $results[] = date('Y-m-d H:i:s', $start); } print_r($results);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 19
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 19
Branch analysis from position: 29
Branch analysis from position: 19
filename:       /in/Ftfpb
function name:  (null)
number of ops:  33
compiled vars:  !0 = $arr, !1 = $interval, !2 = $start, !3 = $end, !4 = $results
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   11     1        ASSIGN                                                   !1, 5
   12     2        INIT_FCALL                                               'roundtonearestminuteinterval'
          3        INIT_FCALL                                               'min'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $7      
          6        SEND_VAR                                                 $7
          7        SEND_VAR                                                 !1
          8        DO_FCALL                                      0  $8      
          9        ASSIGN                                                   !2, $8
   13    10        INIT_FCALL                                               'roundtonearestminuteinterval'
         11        INIT_FCALL                                               'max'
         12        SEND_VAR                                                 !0
         13        DO_ICALL                                         $10     
         14        SEND_VAR                                                 $10
         15        SEND_VAR                                                 !1
         16        DO_FCALL                                      0  $11     
         17        ASSIGN                                                   !3, $11
   14    18      > JMP                                                      ->27
   15    19    >   INIT_FCALL                                               'date'
         20        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                         $14     
         23        ASSIGN_DIM                                               !4
         24        OP_DATA                                                  $14
   14    25        MUL                                              ~15     !1, 60
         26        ASSIGN_OP                                     1          !2, ~15
         27    >   IS_SMALLER_OR_EQUAL                                      !2, !3
         28      > JMPNZ                                                    ~17, ->19
   17    29    >   INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Function roundtonearestminuteinterval:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Ftfpb
function name:  roundToNearestMinuteInterval
number of ops:  17
compiled vars:  !0 = $time, !1 = $interval, !2 = $timestamp, !3 = $rounded
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        INIT_FCALL                                               'strtotime'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $4      
          5        ASSIGN                                                   !2, $4
    7     6        INIT_FCALL                                               'round'
          7        MUL                                              ~6      !1, 60
          8        DIV                                              ~7      !2, ~6
          9        SEND_VAL                                                 ~7
         10        SEND_VAL                                                 0
         11        DO_ICALL                                         $8      
         12        MUL                                              ~9      !1, $8
         13        MUL                                              ~10     ~9, 60
         14        ASSIGN                                                   !3, ~10
    8    15      > RETURN                                                   !3
    9    16*     > RETURN                                                   null

End of function roundtonearestminuteinterval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.98 ms | 1403 KiB | 27 Q