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, ); krsort($array); $newArr = array(); foreach($array as $key => $val) { $i=1; $newArr[$key] = $val; foreach($array as $key2 => $val2){ if($key>$key2 && $i <= 5){ $newArr[$key] += $val2; $i++; } } } var_dump($newArr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 25
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 23
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 23
Branch analysis from position: 13
2 jumps found. (Code = 46) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 22
Branch analysis from position: 18
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 23
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/7AYfT
function name:  (null)
number of ops:  30
compiled vars:  !0 = $array, !1 = $newArr, !2 = $val, !3 = $key, !4 = $i, !5 = $val2, !6 = $key2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   24     1        INIT_FCALL                                                   'krsort'
          2        SEND_REF                                                     !0
          3        DO_ICALL                                                     
   27     4        ASSIGN                                                       !1, <array>
   28     5      > FE_RESET_R                                           $10     !0, ->25
          6    > > FE_FETCH_R                                           ~11     $10, !2, ->25
          7    >   ASSIGN                                                       !3, ~11
   29     8        ASSIGN                                                       !4, 1
   30     9        ASSIGN_DIM                                                   !1, !3
         10        OP_DATA                                                      !2
   31    11      > FE_RESET_R                                           $15     !0, ->23
         12    > > FE_FETCH_R                                           ~16     $15, !5, ->23
         13    >   ASSIGN                                                       !6, ~16
   32    14        IS_SMALLER                                           ~18     !6, !3
         15      > JMPZ_EX                                              ~18     ~18, ->18
         16    >   IS_SMALLER_OR_EQUAL                                  ~19     !4, 5
         17        BOOL                                                 ~18     ~19
         18    > > JMPZ                                                         ~18, ->22
   33    19    >   ASSIGN_DIM_OP                    +=               1          !1, !3
         20        OP_DATA                                                      !5
   34    21        PRE_INC                                                      !4
   31    22    > > JMP                                                          ->12
         23    >   FE_FREE                                                      $15
   28    24      > JMP                                                          ->6
         25    >   FE_FREE                                                      $10
   38    26        INIT_FCALL                                                   'var_dump'
         27        SEND_VAR                                                     !1
         28        DO_ICALL                                                     
         29      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.96 ms | 2344 KiB | 15 Q