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); echo $inbetween / $i[0] / $i[0] / $i[1] . " " . $i[3]; $days = 0; for($n = 0; $n < 12; $n++) { $temp = $inbetween / $i[0] / $i[0] / $i[1]; $tempMonth = date('n', strtotime('-1 year', $second)) - 1; if($temp > $i[5][$tempMonth]) { $temp -= $i[5][$tempMonth]; $days += $i[5][$tempMonth]; //echo "yes"; } else { //echo "fail"; } } $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 . " " . $days . " " . $hours . " " . $minutes . " " . $seconds . " " . $inbetween; } echo calcDays(1388389156, 1419925156);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FENMM
function name:  (null)
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'calcdays'
          1        SEND_VAL                                                 1388389156
          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 = 114
Branch analysis from position: 114
2 jumps found. (Code = 44) Position 1 = 116, Position 2 = 85
Branch analysis from position: 116
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 85
2 jumps found. (Code = 43) Position 1 = 106, Position 2 = 113
Branch analysis from position: 106
1 jumps found. (Code = 42) Position 1 = 113
Branch analysis from position: 113
2 jumps found. (Code = 44) Position 1 = 116, Position 2 = 85
Branch analysis from position: 116
Branch analysis from position: 85
Branch analysis from position: 113
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 114
Branch analysis from position: 114
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/FENMM
function name:  calcDays
number of ops:  163
compiled vars:  !0 = $startdate, !1 = $enddate, !2 = $first, !3 = $second, !4 = $inbetween, !5 = $i, !6 = $days, !7 = $n, !8 = $temp, !9 = $tempMonth, !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        FETCH_DIM_R                                      ~37     !5, 0
         73        DIV                                              ~38     !4, ~37
         74        FETCH_DIM_R                                      ~39     !5, 0
         75        DIV                                              ~40     ~38, ~39
         76        FETCH_DIM_R                                      ~41     !5, 1
         77        DIV                                              ~42     ~40, ~41
         78        CONCAT                                           ~43     ~42, '++'
         79        FETCH_DIM_R                                      ~44     !5, 3
         80        CONCAT                                           ~45     ~43, ~44
         81        ECHO                                                     ~45
   18    82        ASSIGN                                                   !6, 0
   20    83        ASSIGN                                                   !7, 0
         84      > JMP                                                      ->114
   21    85    >   FETCH_DIM_R                                      ~48     !5, 0
         86        DIV                                              ~49     !4, ~48
         87        FETCH_DIM_R                                      ~50     !5, 0
         88        DIV                                              ~51     ~49, ~50
         89        FETCH_DIM_R                                      ~52     !5, 1
         90        DIV                                              ~53     ~51, ~52
         91        ASSIGN                                                   !8, ~53
   22    92        INIT_FCALL                                               'date'
         93        SEND_VAL                                                 'n'
         94        INIT_FCALL                                               'strtotime'
         95        SEND_VAL                                                 '-1+year'
         96        SEND_VAR                                                 !3
         97        DO_ICALL                                         $55     
         98        SEND_VAR                                                 $55
         99        DO_ICALL                                         $56     
        100        SUB                                              ~57     $56, 1
        101        ASSIGN                                                   !9, ~57
   23   102        FETCH_DIM_R                                      ~59     !5, 5
        103        FETCH_DIM_R                                      ~60     ~59, !9
        104        IS_SMALLER                                               ~60, !8
        105      > JMPZ                                                     ~61, ->113
   24   106    >   FETCH_DIM_R                                      ~62     !5, 5
        107        FETCH_DIM_R                                      ~63     ~62, !9
        108        ASSIGN_OP                                     2          !8, ~63
   25   109        FETCH_DIM_R                                      ~65     !5, 5
        110        FETCH_DIM_R                                      ~66     ~65, !9
        111        ASSIGN_OP                                     1          !6, ~66
        112      > JMP                                                      ->113
   20   113    >   PRE_INC                                                  !7
        114    >   IS_SMALLER                                               !7, 12
        115      > JMPNZ                                                    ~69, ->85
   32   116    >   INIT_FCALL                                               'floor'
        117        FETCH_DIM_R                                      ~70     !5, 0
        118        DIV                                              ~71     !4, ~70
        119        FETCH_DIM_R                                      ~72     !5, 0
        120        DIV                                              ~73     ~71, ~72
        121        FETCH_DIM_R                                      ~74     !5, 1
        122        DIV                                              ~75     ~73, ~74
        123        FETCH_DIM_R                                      ~76     !5, 3
        124        DIV                                              ~77     ~75, ~76
        125        FETCH_DIM_R                                      ~78     !5, 4
        126        MOD                                              ~79     ~77, ~78
        127        SEND_VAL                                                 ~79
        128        DO_ICALL                                         $80     
        129        ASSIGN                                                   !10, $80
   34   130        INIT_FCALL                                               'floor'
        131        FETCH_DIM_R                                      ~82     !5, 0
        132        DIV                                              ~83     !4, ~82
        133        FETCH_DIM_R                                      ~84     !5, 0
        134        DIV                                              ~85     ~83, ~84
        135        FETCH_DIM_R                                      ~86     !5, 1
        136        MOD                                              ~87     ~85, ~86
        137        SEND_VAL                                                 ~87
        138        DO_ICALL                                         $88     
        139        ASSIGN                                                   !11, $88
   35   140        INIT_FCALL                                               'floor'
        141        FETCH_DIM_R                                      ~90     !5, 0
        142        DIV                                              ~91     !4, ~90
        143        FETCH_DIM_R                                      ~92     !5, 0
        144        MOD                                              ~93     ~91, ~92
        145        SEND_VAL                                                 ~93
        146        DO_ICALL                                         $94     
        147        ASSIGN                                                   !12, $94
   36   148        FETCH_DIM_R                                      ~96     !5, 0
        149        MOD                                              ~97     !4, ~96
        150        ASSIGN                                                   !13, ~97
   38   151        CONCAT                                           ~99     !10, '+'
        152        CONCAT                                           ~100    ~99, !6
        153        CONCAT                                           ~101    ~100, '+'
        154        CONCAT                                           ~102    ~101, !11
        155        CONCAT                                           ~103    ~102, '+'
        156        CONCAT                                           ~104    ~103, !12
        157        CONCAT                                           ~105    ~104, '+'
        158        CONCAT                                           ~106    ~105, !13
        159        CONCAT                                           ~107    ~106, '+'
        160        CONCAT                                           ~108    ~107, !4
        161      > RETURN                                                   ~108
   39   162*     > RETURN                                                   null

End of function calcdays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.99 ms | 1406 KiB | 20 Q