3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = array( "date_2019_12" => 0, "date_2019_11" => 0, "date_2019_10" => 0, "date_2019_09" => 0, "date_2019_08" => 0, "date_2019_07" => 0, "date_2019_06" => 0, "date_2019_05" => 0, "date_2019_04" => 0, "date_2019_03" => 0, "date_2019_02" => 0, "date_2019_01" => 10, "date_2018_12" => 1, "date_2018_11" => 2, "date_2018_10" => 3, "date_2018_09" => 4, "date_2018_08" => 5, "date_2018_07" => 6, ); $year = 2019; $sums = array(); for ($i = 1; $i <= 12; $i++) { $sum = 0; for ($j = $i - 5; $j <= $i; $j++) { $y = $year; $m = $j; if ($m <= 0) { $m += 12; $y -= 1; } $date = sprintf("date_%4d_%02d", $y, $m); $sum += $array[$date]; } $date = sprintf("date_%4d_%02d", $year, $i); $sums[$date] = $sum; } print_r($sums);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 5
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 9
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 5
Branch analysis from position: 37
Branch analysis from position: 5
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 9
Branch analysis from position: 26
Branch analysis from position: 9
Branch analysis from position: 15
filename:       /in/BhpAG
function name:  (null)
number of ops:  41
compiled vars:  !0 = $array, !1 = $year, !2 = $sums, !3 = $i, !4 = $sum, !5 = $j, !6 = $y, !7 = $m, !8 = $date
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   23     1        ASSIGN                                                       !1, 2019
   24     2        ASSIGN                                                       !2, <array>
   25     3        ASSIGN                                                       !3, 1
          4      > JMP                                                          ->35
   26     5    >   ASSIGN                                                       !4, 0
   27     6        SUB                                                  ~14     !3, 5
          7        ASSIGN                                                       !5, ~14
          8      > JMP                                                          ->24
   28     9    >   ASSIGN                                                       !6, !1
   29    10        ASSIGN                                                       !7, !5
   30    11        IS_SMALLER_OR_EQUAL                                          !7, 0
         12      > JMPZ                                                         ~18, ->15
   31    13    >   ASSIGN_OP                                         1          !7, 12
   32    14        ASSIGN_OP                                         2          !6, 1
   34    15    >   INIT_FCALL                                                   'sprintf'
         16        SEND_VAL                                                     'date_%254d_%2502d'
         17        SEND_VAR                                                     !6
         18        SEND_VAR                                                     !7
         19        DO_ICALL                                             $21     
         20        ASSIGN                                                       !8, $21
   35    21        FETCH_DIM_R                                          ~23     !0, !8
         22        ASSIGN_OP                                         1          !4, ~23
   27    23        PRE_INC                                                      !5
         24    >   IS_SMALLER_OR_EQUAL                                          !5, !3
         25      > JMPNZ                                                        ~26, ->9
   37    26    >   INIT_FCALL                                                   'sprintf'
         27        SEND_VAL                                                     'date_%254d_%2502d'
         28        SEND_VAR                                                     !1
         29        SEND_VAR                                                     !3
         30        DO_ICALL                                             $27     
         31        ASSIGN                                                       !8, $27
   38    32        ASSIGN_DIM                                                   !2, !8
         33        OP_DATA                                                      !4
   25    34        PRE_INC                                                      !3
         35    >   IS_SMALLER_OR_EQUAL                                          !3, 12
         36      > JMPNZ                                                        ~31, ->5
   40    37    >   INIT_FCALL                                                   'print_r'
         38        SEND_VAR                                                     !2
         39        DO_ICALL                                                     
         40      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.82 ms | 2460 KiB | 15 Q