3v4l.org

run code in 300+ PHP versions simultaneously
<?php $Todaysales = array( array("sale_time"=>"2017-09-10","payment_amount"=>1311.45), array("sale_time"=>"2017-09-10","payment_amount"=>1311.46), array("sale_time"=>"2017-09-10","payment_amount"=>175000.00), ); $data = array(); foreach($Todaysales as $d) { $match_key =false; $match_key = array_search($d['sale_time'],array_column($data, "cols")); if($match_key > 0 || $match_key === 0) $data[$match_key]["rows"] = $data[$match_key]["rows"] + $d['payment_amount']; else $data[] = array("cols"=>$d['sale_time'],"rows"=>$d['payment_amount']); } print_r($data);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 35
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 35
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 17, Position 2 = 19
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 28
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 19
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 35
filename:       /in/rmlVh
function name:  (null)
number of ops:  40
compiled vars:  !0 = $Todaysales, !1 = $data, !2 = $d, !3 = $match_key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    7     1        ASSIGN                                                   !1, <array>
    8     2      > FE_RESET_R                                       $6      !0, ->35
          3    > > FE_FETCH_R                                               $6, !2, ->35
   11     4    >   ASSIGN                                                   !3, <false>
   12     5        INIT_FCALL                                               'array_search'
          6        FETCH_DIM_R                                      ~8      !2, 'sale_time'
          7        SEND_VAL                                                 ~8
          8        INIT_FCALL                                               'array_column'
          9        SEND_VAR                                                 !1
         10        SEND_VAL                                                 'cols'
         11        DO_ICALL                                         $9      
         12        SEND_VAR                                                 $9
         13        DO_ICALL                                         $10     
         14        ASSIGN                                                   !3, $10
   14    15        IS_SMALLER                                       ~12     0, !3
         16      > JMPNZ_EX                                         ~12     ~12, ->19
         17    >   IS_IDENTICAL                                     ~13     !3, 0
         18        BOOL                                             ~12     ~13
         19    > > JMPZ                                                     ~12, ->28
   15    20    >   FETCH_DIM_R                                      ~16     !1, !3
         21        FETCH_DIM_R                                      ~17     ~16, 'rows'
         22        FETCH_DIM_R                                      ~18     !2, 'payment_amount'
         23        ADD                                              ~19     ~17, ~18
         24        FETCH_DIM_W                                      $14     !1, !3
         25        ASSIGN_DIM                                               $14, 'rows'
         26        OP_DATA                                                  ~19
   14    27      > JMP                                                      ->34
   17    28    >   FETCH_DIM_R                                      ~21     !2, 'sale_time'
         29        INIT_ARRAY                                       ~22     ~21, 'cols'
         30        FETCH_DIM_R                                      ~23     !2, 'payment_amount'
         31        ADD_ARRAY_ELEMENT                                ~22     ~23, 'rows'
         32        ASSIGN_DIM                                               !1
         33        OP_DATA                                                  ~22
    8    34    > > JMP                                                      ->3
         35    >   FE_FREE                                                  $6
   21    36        INIT_FCALL                                               'print_r'
         37        SEND_VAR                                                 !1
         38        DO_ICALL                                                 
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.91 ms | 1444 KiB | 16 Q