我有两个功能,第一个是:
public function computeGHComponents()
{
error_reporting (E_ALL^ E_NOTICE);
$totals = NULL;
foreach ($this->transaction as $t){
$amount = (float) $t['Amount'];
if (isset($totals[ $t['SiteID'] ][ $t['TransactionType'] ])){
$totals[ $t['SiteID'] ][ $t['TransactionType'] ] += (float) $amount;
} else {
$totals[ $t['SiteID'] ][ $t['TransactionType'] ] = (float) $amount;
}
}
foreach($totals as $key => $value)
{
$this->result[$key]['Deposit'] = isset($value['D']) ? $value['D'] : 0;
$this->result[$key]['Reload'] = isset($value['R']) ? $value['R'] : 0;
$this->result[$key]['Redemption'] = isset($value['W']) ? $value['W'] : 0;
}
echo "<pre>";
print_r($this->result);
}
第二个功能是:
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);
}
现在我需要比较两个 SiteID 才能绑定,这是我的功能:
public function bindGHComponentsToSites()
{
error_reporting (E_ALL^ E_NOTICE);
foreach ($this->arrays as $keys => $data) {
foreach($this->result as $key => $value){
if ($data['SiteID'] == $value['SiteID']){
}
}
}
我曾经呼应 SiteID 的比较,像这样:
echo($data['SiteID'] .'=='.$value['SiteID']);
但是computeGHComponents()函数的$value['SiteID']没有值,它显示如下:
2==
2==
2==
3==
3==
3==
如何从 computeGHComponents() 获取 SiteID 的值?请帮我修改我的代码。先感谢您。