3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( array( 'SiteID' => 147, 'Amount' => '500.00', 'TransactionType' => 'Deposit' ), array( 'SiteID' => 147, 'Amount' => '500.00', 'TransactionType' => 'Redemption'), array( 'SiteID' => 147, 'Amount' => '1500.00', 'TransactionType' => 'Deposit' ), array( 'SiteID' => 147, 'Amount' => '200.00', 'TransactionType' => 'Reload' ), array( 'SiteID' => 150, 'Amount' => '100.00', 'TransactionType' => 'Deposit' ), array( 'SiteID' => 3, 'Amount' => '500.00', 'TransactionType' => 'Redemption' ), array( 'SiteID' => 150, 'Amount' => '200.00', 'TransactionType' => 'Redemption' ), array( 'SiteID' => 3, 'Amount' => '500.00', 'TransactionType' => 'Deposit' ), array( 'SiteID' => 3, 'Amount' => '200.00', 'TransactionType' => 'Deposit' ), array( 'SiteID' => 3, 'Amount' => '200.00', 'TransactionType' => 'Reload' ), array( 'SiteID' =>147, 'Amount' => '500.00', 'TransactionType' => 'Redemption' ) ); $result = []; foreach ($array as ['SiteID' => $id, 'Amount' => $amt, 'TransactionType' => $trn]) { $result[$id][$trn] = ($result[$id][$trn] ?? 0) + $amt; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 20
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 20
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 20
filename:       /in/Wu08E
function name:  (null)
number of ops:  25
compiled vars:  !0 = $array, !1 = $result, !2 = $id, !3 = $amt, !4 = $trn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, <array>
   18     2      > FE_RESET_R                                       $7      !0, ->20
          3    > > FE_FETCH_R                                               $7, $8, ->20
          4    >   FETCH_LIST_R                                     $9      $8, 'SiteID'
          5        ASSIGN                                                   !2, $9
          6        FETCH_LIST_R                                     $11     $8, 'Amount'
          7        ASSIGN                                                   !3, $11
          8        FETCH_LIST_R                                     $13     $8, 'TransactionType'
          9        ASSIGN                                                   !4, $13
         10        FREE                                                     $8
   19    11        FETCH_DIM_IS                                     ~17     !1, !2
         12        FETCH_DIM_IS                                     ~18     ~17, !4
         13        COALESCE                                         ~19     ~18
         14        QM_ASSIGN                                        ~19     0
         15        ADD                                              ~20     ~19, !3
         16        FETCH_DIM_W                                      $15     !1, !2
         17        ASSIGN_DIM                                               $15, !4
         18        OP_DATA                                                  ~20
   18    19      > JMP                                                      ->3
         20    >   FE_FREE                                                  $7
   21    21        INIT_FCALL                                               'var_export'
         22        SEND_VAR                                                 !1
         23        DO_ICALL                                                 
         24      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.57 ms | 1005 KiB | 14 Q