3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = ["01/06/18", "02/06/18", "03/06/18", "11/06/18","12/06/18", "13/06/18", "14/06/18", "15/06/18","16/06/18", "20/06/18"]; $i =-1; $prev =0; $format = "d/m/y"; Foreach($arr as $val){ $dt = date_create_from_format ($format , $val); $unix = date_timestamp_get($dt); If($unix -$prev > 86400){ $i++; If($i>0){ If(count($res[$i-1]) >1){ $periods[] = date($format, min($res[$i-1])) . " - " . date($format, max($res[$i-1])); }Else{ $periods[] = date($format, min($res[$i-1])); } } } $res[$i][] = $unix; $prev = $unix; } If(count(end($res)) >1){ $periods[] = date($format, min(end($res))) . " - " . date($format, max(end($res))); }Else{ $periods[] = date($format, min(end($res))); } Var_dump($periods);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 65
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 65
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 60
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 60
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 26, Position 2 = 49
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 60
Branch analysis from position: 60
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 97
Branch analysis from position: 72
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 97
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 65
filename:       /in/buaCN
function name:  (null)
number of ops:  113
compiled vars:  !0 = $arr, !1 = $i, !2 = $prev, !3 = $format, !4 = $val, !5 = $dt, !6 = $unix, !7 = $res, !8 = $periods
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, -1
    8     2        ASSIGN                                                   !2, 0
    9     3        ASSIGN                                                   !3, 'd%2Fm%2Fy'
   11     4      > FE_RESET_R                                       $13     !0, ->65
          5    > > FE_FETCH_R                                               $13, !4, ->65
   12     6    >   INIT_FCALL                                               'date_create_from_format'
          7        SEND_VAR                                                 !3
          8        SEND_VAR                                                 !4
          9        DO_ICALL                                         $14     
         10        ASSIGN                                                   !5, $14
   13    11        INIT_FCALL                                               'date_timestamp_get'
         12        SEND_VAR                                                 !5
         13        DO_ICALL                                         $16     
         14        ASSIGN                                                   !6, $16
   15    15        SUB                                              ~18     !6, !2
         16        IS_SMALLER                                               86400, ~18
         17      > JMPZ                                                     ~19, ->60
   16    18    >   PRE_INC                                                  !1
   17    19        IS_SMALLER                                               0, !1
         20      > JMPZ                                                     ~21, ->60
   18    21    >   SUB                                              ~22     !1, 1
         22        FETCH_DIM_R                                      ~23     !7, ~22
         23        COUNT                                            ~24     ~23
         24        IS_SMALLER                                               1, ~24
         25      > JMPZ                                                     ~25, ->49
   19    26    >   INIT_FCALL                                               'date'
         27        SEND_VAR                                                 !3
         28        INIT_FCALL                                               'min'
         29        SUB                                              ~27     !1, 1
         30        FETCH_DIM_R                                      ~28     !7, ~27
         31        SEND_VAL                                                 ~28
         32        DO_ICALL                                         $29     
         33        SEND_VAR                                                 $29
         34        DO_ICALL                                         $30     
         35        CONCAT                                           ~31     $30, '+-+'
         36        INIT_FCALL                                               'date'
         37        SEND_VAR                                                 !3
         38        INIT_FCALL                                               'max'
         39        SUB                                              ~32     !1, 1
         40        FETCH_DIM_R                                      ~33     !7, ~32
         41        SEND_VAL                                                 ~33
         42        DO_ICALL                                         $34     
         43        SEND_VAR                                                 $34
         44        DO_ICALL                                         $35     
         45        CONCAT                                           ~36     ~31, $35
         46        ASSIGN_DIM                                               !8
         47        OP_DATA                                                  ~36
   18    48      > JMP                                                      ->60
   21    49    >   INIT_FCALL                                               'date'
         50        SEND_VAR                                                 !3
         51        INIT_FCALL                                               'min'
         52        SUB                                              ~38     !1, 1
         53        FETCH_DIM_R                                      ~39     !7, ~38
         54        SEND_VAL                                                 ~39
         55        DO_ICALL                                         $40     
         56        SEND_VAR                                                 $40
         57        DO_ICALL                                         $41     
         58        ASSIGN_DIM                                               !8
         59        OP_DATA                                                  $41
   25    60    >   FETCH_DIM_W                                      $42     !7, !1
         61        ASSIGN_DIM                                               $42
         62        OP_DATA                                                  !6
   26    63        ASSIGN                                                   !2, !6
   11    64      > JMP                                                      ->5
         65    >   FE_FREE                                                  $13
   29    66        INIT_FCALL                                               'end'
         67        SEND_REF                                                 !7
         68        DO_ICALL                                         $45     
         69        COUNT                                            ~46     $45
         70        IS_SMALLER                                               1, ~46
         71      > JMPZ                                                     ~47, ->97
   30    72    >   INIT_FCALL                                               'date'
         73        SEND_VAR                                                 !3
         74        INIT_FCALL                                               'min'
         75        INIT_FCALL                                               'end'
         76        SEND_REF                                                 !7
         77        DO_ICALL                                         $49     
         78        SEND_VAR                                                 $49
         79        DO_ICALL                                         $50     
         80        SEND_VAR                                                 $50
         81        DO_ICALL                                         $51     
         82        CONCAT                                           ~52     $51, '+-+'
         83        INIT_FCALL                                               'date'
         84        SEND_VAR                                                 !3
         85        INIT_FCALL                                               'max'
         86        INIT_FCALL                                               'end'
         87        SEND_REF                                                 !7
         88        DO_ICALL                                         $53     
         89        SEND_VAR                                                 $53
         90        DO_ICALL                                         $54     
         91        SEND_VAR                                                 $54
         92        DO_ICALL                                         $55     
         93        CONCAT                                           ~56     ~52, $55
         94        ASSIGN_DIM                                               !8
         95        OP_DATA                                                  ~56
   29    96      > JMP                                                      ->109
   32    97    >   INIT_FCALL                                               'date'
         98        SEND_VAR                                                 !3
         99        INIT_FCALL                                               'min'
        100        INIT_FCALL                                               'end'
        101        SEND_REF                                                 !7
        102        DO_ICALL                                         $58     
        103        SEND_VAR                                                 $58
        104        DO_ICALL                                         $59     
        105        SEND_VAR                                                 $59
        106        DO_ICALL                                         $60     
        107        ASSIGN_DIM                                               !8
        108        OP_DATA                                                  $60
   35   109    >   INIT_FCALL                                               'var_dump'
        110        SEND_VAR                                                 !8
        111        DO_ICALL                                                 
        112      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
139.81 ms | 1013 KiB | 20 Q