-3
可能重複:
Printing of Array陣列的印刷
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。請修改了代碼:(
不,我只是打印一次:( – Happy 2012-08-10 08:39:12
有人可以幫我嗎? – Happy 2012-08-10 08:45:48
與我一樣,很多StackOverflow的用戶都住在北美,根據時區不同,它的時間是2-5am。在10分鐘內預計答案有點冒失。 – 2012-08-10 08:52:23