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);
Output for git.master_jit, git.master, rfc.property-hooks
array ( 147 => array ( 'Deposit' => 2000.0, 'Redemption' => 1000.0, 'Reload' => 200.0, ), 150 => array ( 'Deposit' => 100.0, 'Redemption' => 200.0, ), 3 => array ( 'Redemption' => 500.0, 'Deposit' => 700.0, 'Reload' => 200.0, ), )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
27.81 ms | 406 KiB | 5 Q