3v4l.org

run code in 300+ PHP versions simultaneously
<?php function _getRollingMonths($months = 12) { $currentTime = strtotime('2015-01-30'); $dates = array(); for($i=$months-1;$i>=0;$i--) { $dates[] = array( 'year' => date('Y', strtotime("first day of -$i months", $currentTime)), 'month' => date('m', strtotime("first day of -$i months", $currentTime)), 'monthName' => date('M', strtotime("first day of -$i months", $currentTime)) ); } return $dates; } function _getMonths($year = null) { if (!isset($year)) { $year = date('Y'); } $dates = array(); for($month=1;$month<=12;$month++) { $dates[] = array( 'year' => date('Y', strtotime("$year-$month-01")), 'month' => date('m', strtotime("$year-$month-01")), 'monthName' => date('M', strtotime("$year-$month-01")) ); } return $dates; } function _getYTDMonths($year = null) { if (!isset($year)) { $year = date('Y'); } $dates = array(); for($i=date('m')-1;$i>=0;$i--) { $dates[] = array( 'year' => $year, 'month' => date('m', strtotime("first day of -$i months")), 'monthName' => date('M', strtotime("first day of -$i months")) ); if (date('m', strtotime("-$i months")) == date('m')) { $dates[count($dates)-1]['day'] = date('d', strtotime("-$i months")); } } return $dates; } function debug($var) { echo "<pre>"; print_r($var); echo "</pre>"; } debug(date('Y-m-d H:i:s', strtotime('-1 second', strtotime('+1 month', strtotime('2015-01-01 00:00:00')))));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QZ03l
function name:  (null)
number of ops:  19
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   59     0  E >   INIT_FCALL                                               'debug'
          1        INIT_FCALL                                               'date'
          2        SEND_VAL                                                 'Y-m-d+H%3Ai%3As'
          3        INIT_FCALL                                               'strtotime'
          4        SEND_VAL                                                 '-1+second'
          5        INIT_FCALL                                               'strtotime'
          6        SEND_VAL                                                 '%2B1+month'
          7        INIT_FCALL                                               'strtotime'
          8        SEND_VAL                                                 '2015-01-01+00%3A00%3A00'
          9        DO_ICALL                                         $0      
         10        SEND_VAR                                                 $0
         11        DO_ICALL                                         $1      
         12        SEND_VAR                                                 $1
         13        DO_ICALL                                         $2      
         14        SEND_VAR                                                 $2
         15        DO_ICALL                                         $3      
         16        SEND_VAR                                                 $3
         17        DO_FCALL                                      0          
         18      > RETURN                                                   1

Function _getrollingmonths:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 9
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 50, Position 2 = 9
Branch analysis from position: 50
Branch analysis from position: 9
filename:       /in/QZ03l
function name:  _getRollingMonths
number of ops:  52
compiled vars:  !0 = $months, !1 = $currentTime, !2 = $dates, !3 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                        !0      12
    3     1        INIT_FCALL                                               'strtotime'
          2        SEND_VAL                                                 '2015-01-30'
          3        DO_ICALL                                         $4      
          4        ASSIGN                                                   !1, $4
    4     5        ASSIGN                                                   !2, <array>
    5     6        SUB                                              ~7      !0, 1
          7        ASSIGN                                                   !3, ~7
          8      > JMP                                                      ->48
    7     9    >   INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'Y'
         11        INIT_FCALL                                               'strtotime'
         12        ROPE_INIT                                     3  ~11     'first+day+of+-'
         13        ROPE_ADD                                      1  ~11     ~11, !3
         14        ROPE_END                                      2  ~10     ~11, '+months'
         15        SEND_VAL                                                 ~10
         16        SEND_VAR                                                 !1
         17        DO_ICALL                                         $13     
         18        SEND_VAR                                                 $13
         19        DO_ICALL                                         $14     
         20        INIT_ARRAY                                       ~15     $14, 'year'
    8    21        INIT_FCALL                                               'date'
         22        SEND_VAL                                                 'm'
         23        INIT_FCALL                                               'strtotime'
         24        ROPE_INIT                                     3  ~17     'first+day+of+-'
         25        ROPE_ADD                                      1  ~17     ~17, !3
         26        ROPE_END                                      2  ~16     ~17, '+months'
         27        SEND_VAL                                                 ~16
         28        SEND_VAR                                                 !1
         29        DO_ICALL                                         $19     
         30        SEND_VAR                                                 $19
         31        DO_ICALL                                         $20     
         32        ADD_ARRAY_ELEMENT                                ~15     $20, 'month'
    9    33        INIT_FCALL                                               'date'
         34        SEND_VAL                                                 'M'
         35        INIT_FCALL                                               'strtotime'
         36        ROPE_INIT                                     3  ~22     'first+day+of+-'
         37        ROPE_ADD                                      1  ~22     ~22, !3
         38        ROPE_END                                      2  ~21     ~22, '+months'
         39        SEND_VAL                                                 ~21
         40        SEND_VAR                                                 !1
         41        DO_ICALL                                         $24     
         42        SEND_VAR                                                 $24
         43        DO_ICALL                                         $25     
         44        ADD_ARRAY_ELEMENT                                ~15     $25, 'monthName'
    6    45        ASSIGN_DIM                                               !2
    9    46        OP_DATA                                                  ~15
    5    47        PRE_DEC                                                  !3
         48    >   IS_SMALLER_OR_EQUAL                                      0, !3
         49      > JMPNZ                                                    ~27, ->9
   13    50    > > RETURN                                                   !2
   14    51*     > RETURN                                                   null

End of function _getrollingmonths

Function _getmonths:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 50
Branch analysis from position: 50
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 11
Branch analysis from position: 52
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 52, Position 2 = 11
Branch analysis from position: 52
Branch analysis from position: 11
Branch analysis from position: 8
filename:       /in/QZ03l
function name:  _getMonths
number of ops:  54
compiled vars:  !0 = $year, !1 = $dates, !2 = $month
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV_INIT                                        !0      null
   17     1        ISSET_ISEMPTY_CV                                 ~3      !0
          2        BOOL_NOT                                         ~4      ~3
          3      > JMPZ                                                     ~4, ->8
   18     4    >   INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'Y'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   21     8    >   ASSIGN                                                   !1, <array>
   22     9        ASSIGN                                                   !2, 1
         10      > JMP                                                      ->50
   24    11    >   INIT_FCALL                                               'date'
         12        SEND_VAL                                                 'Y'
         13        INIT_FCALL                                               'strtotime'
         14        ROPE_INIT                                     4  ~11     !0
         15        ROPE_ADD                                      1  ~11     ~11, '-'
         16        ROPE_ADD                                      2  ~11     ~11, !2
         17        ROPE_END                                      3  ~10     ~11, '-01'
         18        SEND_VAL                                                 ~10
         19        DO_ICALL                                         $13     
         20        SEND_VAR                                                 $13
         21        DO_ICALL                                         $14     
         22        INIT_ARRAY                                       ~15     $14, 'year'
   25    23        INIT_FCALL                                               'date'
         24        SEND_VAL                                                 'm'
         25        INIT_FCALL                                               'strtotime'
         26        ROPE_INIT                                     4  ~17     !0
         27        ROPE_ADD                                      1  ~17     ~17, '-'
         28        ROPE_ADD                                      2  ~17     ~17, !2
         29        ROPE_END                                      3  ~16     ~17, '-01'
         30        SEND_VAL                                                 ~16
         31        DO_ICALL                                         $19     
         32        SEND_VAR                                                 $19
         33        DO_ICALL                                         $20     
         34        ADD_ARRAY_ELEMENT                                ~15     $20, 'month'
   26    35        INIT_FCALL                                               'date'
         36        SEND_VAL                                                 'M'
         37        INIT_FCALL                                               'strtotime'
         38        ROPE_INIT                                     4  ~22     !0
         39        ROPE_ADD                                      1  ~22     ~22, '-'
         40        ROPE_ADD                                      2  ~22     ~22, !2
         41        ROPE_END                                      3  ~21     ~22, '-01'
         42        SEND_VAL                                                 ~21
         43        DO_ICALL                                         $24     
         44        SEND_VAR                                                 $24
         45        DO_ICALL                                         $25     
         46        ADD_ARRAY_ELEMENT                                ~15     $25, 'monthName'
   23    47        ASSIGN_DIM                                               !1
   26    48        OP_DATA                                                  ~15
   22    49        PRE_INC                                                  !2
         50    >   IS_SMALLER_OR_EQUAL                                      !2, 12
         51      > JMPNZ                                                    ~27, ->11
   30    52    > > RETURN                                                   !1
   31    53*     > RETURN                                                   null

End of function _getmonths

Function _getytdmonths:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 8
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 71
Branch analysis from position: 71
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 15
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 55, Position 2 = 70
Branch analysis from position: 55
2 jumps found. (Code = 44) Position 1 = 73, Position 2 = 15
Branch analysis from position: 73
Branch analysis from position: 15
Branch analysis from position: 70
Branch analysis from position: 8
filename:       /in/QZ03l
function name:  _getYTDMonths
number of ops:  75
compiled vars:  !0 = $year, !1 = $dates, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV_INIT                                        !0      null
   34     1        ISSET_ISEMPTY_CV                                 ~3      !0
          2        BOOL_NOT                                         ~4      ~3
          3      > JMPZ                                                     ~4, ->8
   35     4    >   INIT_FCALL                                               'date'
          5        SEND_VAL                                                 'Y'
          6        DO_ICALL                                         $5      
          7        ASSIGN                                                   !0, $5
   38     8    >   ASSIGN                                                   !1, <array>
   39     9        INIT_FCALL                                               'date'
         10        SEND_VAL                                                 'm'
         11        DO_ICALL                                         $8      
         12        SUB                                              ~9      $8, 1
         13        ASSIGN                                                   !2, ~9
         14      > JMP                                                      ->71
   41    15    >   INIT_ARRAY                                       ~12     !0, 'year'
   42    16        INIT_FCALL                                               'date'
         17        SEND_VAL                                                 'm'
         18        INIT_FCALL                                               'strtotime'
         19        ROPE_INIT                                     3  ~14     'first+day+of+-'
         20        ROPE_ADD                                      1  ~14     ~14, !2
         21        ROPE_END                                      2  ~13     ~14, '+months'
         22        SEND_VAL                                                 ~13
         23        DO_ICALL                                         $16     
         24        SEND_VAR                                                 $16
         25        DO_ICALL                                         $17     
         26        ADD_ARRAY_ELEMENT                                ~12     $17, 'month'
   43    27        INIT_FCALL                                               'date'
         28        SEND_VAL                                                 'M'
         29        INIT_FCALL                                               'strtotime'
         30        ROPE_INIT                                     3  ~19     'first+day+of+-'
         31        ROPE_ADD                                      1  ~19     ~19, !2
         32        ROPE_END                                      2  ~18     ~19, '+months'
         33        SEND_VAL                                                 ~18
         34        DO_ICALL                                         $21     
         35        SEND_VAR                                                 $21
         36        DO_ICALL                                         $22     
         37        ADD_ARRAY_ELEMENT                                ~12     $22, 'monthName'
   40    38        ASSIGN_DIM                                               !1
   43    39        OP_DATA                                                  ~12
   45    40        INIT_FCALL                                               'date'
         41        SEND_VAL                                                 'm'
         42        INIT_FCALL                                               'strtotime'
         43        ROPE_INIT                                     3  ~24     '-'
         44        ROPE_ADD                                      1  ~24     ~24, !2
         45        ROPE_END                                      2  ~23     ~24, '+months'
         46        SEND_VAL                                                 ~23
         47        DO_ICALL                                         $26     
         48        SEND_VAR                                                 $26
         49        DO_ICALL                                         $27     
         50        INIT_FCALL                                               'date'
         51        SEND_VAL                                                 'm'
         52        DO_ICALL                                         $28     
         53        IS_EQUAL                                                 $27, $28
         54      > JMPZ                                                     ~29, ->70
   46    55    >   COUNT                                            ~30     !1
         56        SUB                                              ~31     ~30, 1
         57        INIT_FCALL                                               'date'
         58        SEND_VAL                                                 'd'
         59        INIT_FCALL                                               'strtotime'
         60        ROPE_INIT                                     3  ~35     '-'
         61        ROPE_ADD                                      1  ~35     ~35, !2
         62        ROPE_END                                      2  ~34     ~35, '+months'
         63        SEND_VAL                                                 ~34
         64        DO_ICALL                                         $37     
         65        SEND_VAR                                                 $37
         66        DO_ICALL                                         $38     
         67        FETCH_DIM_W                                      $32     !1, ~31
         68        ASSIGN_DIM                                               $32, 'day'
         69        OP_DATA                                                  $38
   39    70    >   PRE_DEC                                                  !2
         71    >   IS_SMALLER_OR_EQUAL                                      0, !2
         72      > JMPNZ                                                    ~40, ->15
   50    73    > > RETURN                                                   !1
   51    74*     > RETURN                                                   null

End of function _getytdmonths

Function debug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QZ03l
function name:  debug
number of ops:  7
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
   54     1        ECHO                                                     '%3Cpre%3E'
   55     2        INIT_FCALL                                               'print_r'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   56     5        ECHO                                                     '%3C%2Fpre%3E'
   57     6      > RETURN                                                   null

End of function debug

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.83 ms | 1419 KiB | 20 Q