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

End of function calcdays

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.43 ms | 1411 KiB | 22 Q