3v4l.org

run code in 300+ PHP versions simultaneously
<?php $range1 = '2019-01-01 - 2019-05-20'; $range2 = '2019-01-06 - 2019-05-20'; list($start, $end) = explode(' - ', $range1); $start1 = new DateTime($start); $end1 = new DateTime($end); list($start, $end) = explode(' - ', $range2); $start2 = new DateTime($start); $end2 = new DateTime($end); if ($end1 > $start1) { $overlap = $end1->diff(min($start2, $end2)); } else { $overlap = $start1->diff(min($start2, $end2)); } echo "overlap is " . ($overlap->format('%a') + 1) . " days";
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 38, Position 2 = 47
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 55
Branch analysis from position: 55
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AlhZB
function name:  (null)
number of ops:  63
compiled vars:  !0 = $range1, !1 = $range2, !2 = $start, !3 = $end, !4 = $start1, !5 = $end1, !6 = $start2, !7 = $end2, !8 = $overlap
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, '2019-01-01+-+2019-05-20'
    3     1        ASSIGN                                                   !1, '2019-01-06+-+2019-05-20'
    4     2        INIT_FCALL                                               'explode'
          3        SEND_VAL                                                 '+-+'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $11     
          6        FETCH_LIST_R                                     $12     $11, 0
          7        ASSIGN                                                   !2, $12
          8        FETCH_LIST_R                                     $14     $11, 1
          9        ASSIGN                                                   !3, $14
         10        FREE                                                     $11
    5    11        NEW                                              $16     'DateTime'
         12        SEND_VAR_EX                                              !2
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !4, $16
    6    15        NEW                                              $19     'DateTime'
         16        SEND_VAR_EX                                              !3
         17        DO_FCALL                                      0          
         18        ASSIGN                                                   !5, $19
    7    19        INIT_FCALL                                               'explode'
         20        SEND_VAL                                                 '+-+'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $22     
         23        FETCH_LIST_R                                     $23     $22, 0
         24        ASSIGN                                                   !2, $23
         25        FETCH_LIST_R                                     $25     $22, 1
         26        ASSIGN                                                   !3, $25
         27        FREE                                                     $22
    8    28        NEW                                              $27     'DateTime'
         29        SEND_VAR_EX                                              !2
         30        DO_FCALL                                      0          
         31        ASSIGN                                                   !6, $27
    9    32        NEW                                              $30     'DateTime'
         33        SEND_VAR_EX                                              !3
         34        DO_FCALL                                      0          
         35        ASSIGN                                                   !7, $30
   10    36        IS_SMALLER                                               !4, !5
         37      > JMPZ                                                     ~33, ->47
   11    38    >   INIT_METHOD_CALL                                         !5, 'diff'
         39        INIT_FCALL                                               'min'
         40        SEND_VAR                                                 !6
         41        SEND_VAR                                                 !7
         42        DO_ICALL                                         $34     
         43        SEND_VAR_NO_REF_EX                                       $34
         44        DO_FCALL                                      0  $35     
         45        ASSIGN                                                   !8, $35
   10    46      > JMP                                                      ->55
   14    47    >   INIT_METHOD_CALL                                         !4, 'diff'
         48        INIT_FCALL                                               'min'
         49        SEND_VAR                                                 !6
         50        SEND_VAR                                                 !7
         51        DO_ICALL                                         $37     
         52        SEND_VAR_NO_REF_EX                                       $37
         53        DO_FCALL                                      0  $38     
         54        ASSIGN                                                   !8, $38
   16    55    >   INIT_METHOD_CALL                                         !8, 'format'
         56        SEND_VAL_EX                                              '%25a'
         57        DO_FCALL                                      0  $40     
         58        ADD                                              ~41     $40, 1
         59        CONCAT                                           ~42     'overlap+is+', ~41
         60        CONCAT                                           ~43     ~42, '+days'
         61        ECHO                                                     ~43
         62      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.67 ms | 1004 KiB | 15 Q