可能重复:
阵列打印
public function computeGHComponents()
{
error_reporting (E_ALL^ E_NOTICE);
$total = null;
$result=array();
foreach ($this->transaction as $t){
$amount = (float) $t['Amount'];
if (isset($this->totals[ $t['SiteID'] ][ $t['TransactionType'] ])){
$this->totals[ $t['SiteID'] ][ $t['TransactionType'] ] += (float) $amount;
} else {
$this->totals[ $t['SiteID'] ][ $t['TransactionType'] ] = (float) $amount;
}
}
foreach($this->totals as $key => $value)
{
$result = array_merge($result,array($key=>array("Deposit"=>$value['D'],"Redemption"=>$value['W'],"Reload"=>$value['R'])));
}
print_r($result);
}
关键应该是 SiteID,我该怎么做?
我需要这种输出:
array ([147]=>array([Deposit] => "total amount", [Reload]=> "total amount" [Redemption]=> "total amount"))
array ([150]=>array([Deposit] => "total amount", [Reload]=> "total amount" [Redemption]=> "total amount"))
array ([3]=> array([Deposit] => "total amount", [Reload]=> "total amount" [Redemption]=> "total amount"))
键应该是 SiteID。请修改代码:(