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

End of function calcdays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.91 ms | 1415 KiB | 20 Q