我有两个功能,第一个是:
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的值?请帮我修改我的代码。提前谢谢。
答案 0 :(得分:1)
我曾经打印过我的$ keyss,我发现它是SiteID所以我修改了我的代码:
public function bindGHComponentsToSites()
{
error_reporting (E_ALL^ E_NOTICE);
foreach ($this->arrays as $keys => $data) {
foreach($this->result as $keyss => $value){
//print_r($keyss );echo '<br/>';
if($data['SiteID'] == $keyss){
//statement...
}
}
}