我在这里有两个功能:
public function bindOwnerToSites(){
error_reporting (E_ALL^ E_NOTICE);
foreach( $this->balance as $keysaa =>$key_valuesa)//getsitebalance
{
foreach( $this->sites as $keys=>$key_values)//getsites
{
if ($key_values['SiteID'] == $key_valuesa['SiteID'])
{
$this->arrays[$key_valuesa['SiteID']] = array('SiteID'=>$key_valuesa['SiteID'],'Balance'=>$key_valuesa['Balance'],'MinBalance'=>$key_valuesa['MinBalance'],'MaxBalance'=>$key_valuesa['MaxBalance'],'OwnerAID'=>$key_values['OwnerAID'],'GroupID'=>1);
}
}
}
print_r ($this->arrays,$return=null);
}
bindOwnerToSites() 的输出如下所示:
Array
(
[1] => Array
(
[SiteID] => 1
[Balance] => 2000
[MinBalance] => 1000
[MaxBalance] => 500
[OwnerAID] => 1
[GroupID] => 1
)
)
这是第二个函数的代码:
public function computeGHComponents()
{
error_reporting (E_ALL^ E_NOTICE);
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)
{
$this->result[$key] = array("Deposit"=>$value['D'], "Redemption"=>$value['W'], "Reload"=>$value['R']);
}
print_r($this->result);
}
computeGHComponents() 的输出如下所示:
Array
(
[1] => Array
(
[Deposit] => 10000
[Redemption] => 500.00
[Reload] => 200.00
)
)
现在,我需要绑定这两个函数的结果,我会自己尝试,但我的代码有问题,我需要你的帮助,我把所有的东西都放在这里,希望你能更好地了解我想实现的目标。这是我的绑定代码:
public function bindGHComponentsToSites()
{
error_reporting (E_ALL^ E_NOTICE);
$combined = array();
foreach($this->arrays as $key => $key_value){
foreach($this->result as $keys => $key_values){
$combined[$key_values['SiteID']] = array_merge((array)$key_value, (array)$key_values);
}
}
print_r($combined);
}
结果应该是这样的,我怎么会有这样的结果?这个问题需要你的耐心,我只是一个初学者,所以希望你能理解。
Array
(
[1] => Array
(
[SiteID] => 1
[Balance] => 2000
[MinBalance] => 1000
[MaxBalance] => 500
[OwnerAID] => 1
[GroupID] => 1
[Deposit] => 10000.00
[Redemption] => 500.00
[Reload] => 200.00
)
)
在此先感谢,请以正确的方式指导我。