3v4l.org

run code in 300+ PHP versions simultaneously
<?php $originArr=array( array('amount'=>100,'date'=>'2014-03-29'), array('amount'=>120,'date'=>'2014-03-30'), array('amount'=>200,'date'=>'2014-03-31') ); $newArr1 = array(); $newArr2 = array(); $tempArr = array(); $resultArr = array(); foreach($originArr as $el) { $newArr1[$el['date']] = $el['amount']; } foreach ($newArr1 as $k1 => $v1) { foreach ($newArr1 as $k2 => $v2) { $v1 += ($k1 > $k2) ? $v2 : 0; } $newArr2[$k1] = $v1; } foreach($newArr2 as $key => $value) { $tempArr['amount'] = $value; $tempArr['date'] = $key; $resultArr[] = $tempArr; } var_dump($resultArr);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 12
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 12
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 12
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 30
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 30
Branch analysis from position: 15
2 jumps found. (Code = 77) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 78) Position 1 = 18, Position 2 = 26
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 23
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 26
Branch analysis from position: 30
2 jumps found. (Code = 77) Position 1 = 32, Position 2 = 41
Branch analysis from position: 32
2 jumps found. (Code = 78) Position 1 = 33, Position 2 = 41
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 41
Branch analysis from position: 30
Branch analysis from position: 12
filename:       /in/MHb2N
function name:  (null)
number of ops:  46
compiled vars:  !0 = $originArr, !1 = $newArr1, !2 = $newArr2, !3 = $tempArr, !4 = $resultArr, !5 = $el, !6 = $v1, !7 = $k1, !8 = $v2, !9 = $k2, !10 = $value, !11 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
    9     2        ASSIGN                                                   !2, <array>
   10     3        ASSIGN                                                   !3, <array>
   11     4        ASSIGN                                                   !4, <array>
   13     5      > FE_RESET_R                                       $17     !0, ->12
          6    > > FE_FETCH_R                                               $17, !5, ->12
   14     7    >   FETCH_DIM_R                                      ~18     !5, 'date'
          8        FETCH_DIM_R                                      ~20     !5, 'amount'
          9        ASSIGN_DIM                                               !1, ~18
         10        OP_DATA                                                  ~20
   13    11      > JMP                                                      ->6
         12    >   FE_FREE                                                  $17
   17    13      > FE_RESET_R                                       $21     !1, ->30
         14    > > FE_FETCH_R                                       ~22     $21, !6, ->30
         15    >   ASSIGN                                                   !7, ~22
   18    16      > FE_RESET_R                                       $24     !1, ->26
         17    > > FE_FETCH_R                                       ~25     $24, !8, ->26
         18    >   ASSIGN                                                   !9, ~25
   19    19        IS_SMALLER                                               !9, !7
         20      > JMPZ                                                     ~27, ->23
         21    >   QM_ASSIGN                                        ~28     !8
         22      > JMP                                                      ->24
         23    >   QM_ASSIGN                                        ~28     0
         24    >   ASSIGN_OP                                     1          !6, ~28
   18    25      > JMP                                                      ->17
         26    >   FE_FREE                                                  $24
   21    27        ASSIGN_DIM                                               !2, !7
         28        OP_DATA                                                  !6
   17    29      > JMP                                                      ->14
         30    >   FE_FREE                                                  $21
   24    31      > FE_RESET_R                                       $31     !2, ->41
         32    > > FE_FETCH_R                                       ~32     $31, !10, ->41
         33    >   ASSIGN                                                   !11, ~32
   25    34        ASSIGN_DIM                                               !3, 'amount'
         35        OP_DATA                                                  !10
   26    36        ASSIGN_DIM                                               !3, 'date'
         37        OP_DATA                                                  !11
   27    38        ASSIGN_DIM                                               !4
         39        OP_DATA                                                  !3
   24    40      > JMP                                                      ->32
         41    >   FE_FREE                                                  $31
   29    42        INIT_FCALL                                               'var_dump'
         43        SEND_VAR                                                 !4
         44        DO_ICALL                                                 
         45      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.63 ms | 1400 KiB | 15 Q