3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calcDays($startdate, $enddate) { $first = $startdate < $enddate ? $startdate : $enddate; $second = $startdate < $enddate ? $enddate : $startdate; $inbetween = $second - $first; $i[0] = 60; $i[1] = 24; $i[2] = 7; $i[3] = date('t', strtotime('-1 month', $second)); $i[4] = date('L', strtotime('-1 year', $second)) ? 366 : 365; $i[5] = array(31, (date('L', strtotime('-1 year', $second)) ? 28 : 29), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); $days = 0; $temp = floor($inbetween / $i[0] / $i[0] / $i[1]); $tempMonth = date('n', strtotime('-1 year', $second)) - 1; for($n = 0; $n < 12; $n++) { if($temp >= $i[5][$tempMonth]) { $temp -= $i[5][$tempMonth]; } else { $days = $temp; break; } var_dump($tempMonth); $tempMonth = $tempMonth < 10 ? $tempMonth + 1 : 0; } $month = floor($inbetween / $i[0] / $i[0] / $i[1] / $i[3] % $i[4]); //$days = floor($inbetween / $i[0] / $i[0] / $i[1] % $i[3]); $hours = floor($inbetween / $i[0] / $i[0] % $i[1]); $minutes = floor($inbetween / $i[0] % $i[0]); $seconds = $inbetween % $i[0]; return $month . " months " . $days . " days " . $hours . " hours " . $minutes . " minutes " . $seconds . " seconds";; } echo calcDays(1388389157, 1419925156);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EDXZQ
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   INIT_FCALL                                               'calcdays'
          1        SEND_VAL                                                 1388389157
          2        SEND_VAL                                                 1419925156
          3        DO_FCALL                                      0  $0      
          4        ECHO                                                     $0
          5      > RETURN                                                   1

Function calcdays:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
1 jumps found. (Code = 42) Position 1 = 44
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
1 jumps found. (Code = 42) Position 1 = 116
Branch analysis from position: 116
2 jumps found. (Code = 44) Position 1 = 118, Position 2 = 95
Branch analysis from position: 118
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 95
2 jumps found. (Code = 43) Position 1 = 99, Position 2 = 103
Branch analysis from position: 99
1 jumps found. (Code = 42) Position 1 = 105
Branch analysis from position: 105
2 jumps found. (Code = 43) Position 1 = 110, Position 2 = 113
Branch analysis from position: 110
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
2 jumps found. (Code = 44) Position 1 = 118, Position 2 = 95
Branch analysis from position: 118
Branch analysis from position: 95
Branch analysis from position: 113
2 jumps found. (Code = 44) Position 1 = 118, Position 2 = 95
Branch analysis from position: 118
Branch analysis from position: 95
Branch analysis from position: 103
1 jumps found. (Code = 42) Position 1 = 118
Branch analysis from position: 118
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 116
Branch analysis from position: 116
Branch analysis from position: 43
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
Branch analysis from position: 58
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 41, Position 2 = 43
Branch analysis from position: 41
Branch analysis from position: 43
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
Branch analysis from position: 12
filename:       /in/EDXZQ
function name:  calcDays
number of ops:  164
compiled vars:  !0 = $startdate, !1 = $enddate, !2 = $first, !3 = $second, !4 = $inbetween, !5 = $i, !6 = $days, !7 = $temp, !8 = $tempMonth, !9 = $n, !10 = $month, !11 = $hours, !12 = $minutes, !13 = $seconds
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        IS_SMALLER                                               !0, !1
          3      > JMPZ                                                     ~14, ->6
          4    >   QM_ASSIGN                                        ~15     !0
          5      > JMP                                                      ->7
          6    >   QM_ASSIGN                                        ~15     !1
          7    >   ASSIGN                                                   !2, ~15
    5     8        IS_SMALLER                                               !0, !1
          9      > JMPZ                                                     ~17, ->12
         10    >   QM_ASSIGN                                        ~18     !1
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~18     !0
         13    >   ASSIGN                                                   !3, ~18
    6    14        SUB                                              ~20     !3, !2
         15        ASSIGN                                                   !4, ~20
    8    16        ASSIGN_DIM                                               !5, 0
         17        OP_DATA                                                  60
    9    18        ASSIGN_DIM                                               !5, 1
         19        OP_DATA                                                  24
   10    20        ASSIGN_DIM                                               !5, 2
         21        OP_DATA                                                  7
   11    22        INIT_FCALL                                               'date'
         23        SEND_VAL                                                 't'
         24        INIT_FCALL                                               'strtotime'
         25        SEND_VAL                                                 '-1+month'
         26        SEND_VAR                                                 !3
         27        DO_ICALL                                         $26     
         28        SEND_VAR                                                 $26
         29        DO_ICALL                                         $27     
         30        ASSIGN_DIM                                               !5, 3
         31        OP_DATA                                                  $27
   12    32        INIT_FCALL                                               'date'
         33        SEND_VAL                                                 'L'
         34        INIT_FCALL                                               'strtotime'
         35        SEND_VAL                                                 '-1+year'
         36        SEND_VAR                                                 !3
         37        DO_ICALL                                         $29     
         38        SEND_VAR                                                 $29
         39        DO_ICALL                                         $30     
         40      > JMPZ                                                     $30, ->43
         41    >   QM_ASSIGN                                        ~31     366
         42      > JMP                                                      ->44
         43    >   QM_ASSIGN                                        ~31     365
         44    >   ASSIGN_DIM                                               !5, 4
         45        OP_DATA                                                  ~31
   13    46        INIT_ARRAY                                       ~33     31
         47        INIT_FCALL                                               'date'
         48        SEND_VAL                                                 'L'
         49        INIT_FCALL                                               'strtotime'
         50        SEND_VAL                                                 '-1+year'
         51        SEND_VAR                                                 !3
         52        DO_ICALL                                         $34     
         53        SEND_VAR                                                 $34
         54        DO_ICALL                                         $35     
         55      > JMPZ                                                     $35, ->58
         56    >   QM_ASSIGN                                        ~36     28
         57      > JMP                                                      ->59
         58    >   QM_ASSIGN                                        ~36     29
         59    >   ADD_ARRAY_ELEMENT                                ~33     ~36
         60        ADD_ARRAY_ELEMENT                                ~33     31
         61        ADD_ARRAY_ELEMENT                                ~33     30
         62        ADD_ARRAY_ELEMENT                                ~33     31
         63        ADD_ARRAY_ELEMENT                                ~33     30
         64        ADD_ARRAY_ELEMENT                                ~33     31
         65        ADD_ARRAY_ELEMENT                                ~33     31
         66        ADD_ARRAY_ELEMENT                                ~33     30
         67        ADD_ARRAY_ELEMENT                                ~33     31
         68        ADD_ARRAY_ELEMENT                                ~33     30
         69        ADD_ARRAY_ELEMENT                                ~33     31
         70        ASSIGN_DIM                                               !5, 5
         71        OP_DATA                                                  ~33
   15    72        ASSIGN                                                   !6, 0
   17    73        INIT_FCALL                                               'floor'
         74        FETCH_DIM_R                                      ~38     !5, 0
         75        DIV                                              ~39     !4, ~38
         76        FETCH_DIM_R                                      ~40     !5, 0
         77        DIV                                              ~41     ~39, ~40
         78        FETCH_DIM_R                                      ~42     !5, 1
         79        DIV                                              ~43     ~41, ~42
         80        SEND_VAL                                                 ~43
         81        DO_ICALL                                         $44     
         82        ASSIGN                                                   !7, $44
   18    83        INIT_FCALL                                               'date'
         84        SEND_VAL                                                 'n'
         85        INIT_FCALL                                               'strtotime'
         86        SEND_VAL                                                 '-1+year'
         87        SEND_VAR                                                 !3
         88        DO_ICALL                                         $46     
         89        SEND_VAR                                                 $46
         90        DO_ICALL                                         $47     
         91        SUB                                              ~48     $47, 1
         92        ASSIGN                                                   !8, ~48
   20    93        ASSIGN                                                   !9, 0
         94      > JMP                                                      ->116
   21    95    >   FETCH_DIM_R                                      ~51     !5, 5
         96        FETCH_DIM_R                                      ~52     ~51, !8
         97        IS_SMALLER_OR_EQUAL                                      ~52, !7
         98      > JMPZ                                                     ~53, ->103
   22    99    >   FETCH_DIM_R                                      ~54     !5, 5
        100        FETCH_DIM_R                                      ~55     ~54, !8
        101        ASSIGN_OP                                     2          !7, ~55
        102      > JMP                                                      ->105
   24   103    >   ASSIGN                                                   !6, !7
   25   104      > JMP                                                      ->118
   29   105    >   INIT_FCALL                                               'var_dump'
        106        SEND_VAR                                                 !8
        107        DO_ICALL                                                 
   30   108        IS_SMALLER                                               !8, 10
        109      > JMPZ                                                     ~59, ->113
        110    >   ADD                                              ~60     !8, 1
        111        QM_ASSIGN                                        ~61     ~60
        112      > JMP                                                      ->114
        113    >   QM_ASSIGN                                        ~61     0
        114    >   ASSIGN                                                   !8, ~61
   20   115        PRE_INC                                                  !9
        116    >   IS_SMALLER                                               !9, 12
        117      > JMPNZ                                                    ~64, ->95
   34   118    >   INIT_FCALL                                               'floor'
        119        FETCH_DIM_R                                      ~65     !5, 0
        120        DIV                                              ~66     !4, ~65
        121        FETCH_DIM_R                                      ~67     !5, 0
        122        DIV                                              ~68     ~66, ~67
        123        FETCH_DIM_R                                      ~69     !5, 1
        124        DIV                                              ~70     ~68, ~69
        125        FETCH_DIM_R                                      ~71     !5, 3
        126        DIV                                              ~72     ~70, ~71
        127        FETCH_DIM_R                                      ~73     !5, 4
        128        MOD                                              ~74     ~72, ~73
        129        SEND_VAL                                                 ~74
        130        DO_ICALL                                         $75     
        131        ASSIGN                                                   !10, $75
   36   132        INIT_FCALL                                               'floor'
        133        FETCH_DIM_R                                      ~77     !5, 0
        134        DIV                                              ~78     !4, ~77
        135        FETCH_DIM_R                                      ~79     !5, 0
        136        DIV                                              ~80     ~78, ~79
        137        FETCH_DIM_R                                      ~81     !5, 1
        138        MOD                                              ~82     ~80, ~81
        139        SEND_VAL                                                 ~82
        140        DO_ICALL                                         $83     
        141        ASSIGN                                                   !11, $83
   37   142        INIT_FCALL                                               'floor'
        143        FETCH_DIM_R                                      ~85     !5, 0
        144        DIV                                              ~86     !4, ~85
        145        FETCH_DIM_R                                      ~87     !5, 0
        146        MOD                                              ~88     ~86, ~87
        147        SEND_VAL                                                 ~88
        148        DO_ICALL                                         $89     
        149        ASSIGN                                                   !12, $89
   38   150        FETCH_DIM_R                                      ~91     !5, 0
        151        MOD                                              ~92     !4, ~91
        152        ASSIGN                                                   !13, ~92
   40   153        CONCAT                                           ~94     !10, '+months+'
        154        CONCAT                                           ~95     ~94, !6
        155        CONCAT                                           ~96     ~95, '+days+'
        156        CONCAT                                           ~97     ~96, !11
        157        CONCAT                                           ~98     ~97, '+hours+'
        158        CONCAT                                           ~99     ~98, !12
        159        CONCAT                                           ~100    ~99, '+minutes+'
        160        CONCAT                                           ~101    ~100, !13
        161        CONCAT                                           ~102    ~101, '+seconds'
        162      > RETURN                                                   ~102
   41   163*     > RETURN                                                   null

End of function calcdays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.65 ms | 1415 KiB | 22 Q