我这里有数据:
这是我的第一个函数的结果。我用于结果的变量是 $this->arrays。
Array
(
[1] => Array //Transactiondetails of SiteID 1
(
[SiteID] => 1
[Balance] => 2000
[MinBalance] => 1000
[MaxBalance] => 500
[OwnerAID] => 1
[GroupID] => 1
[Deposit] => 10000
[Reload] => 0
[Redemption] => 0
)
)
现在,这是我的第二个函数的结果。我用于结果的变量是 $this->combined。
Array
(
[0] => Array
(
[AID] => 1
[Sites] => Array
(
[0] => 1 //List of SiteID owned by AID
[1] => 5
)
)
[1] => Array
(
[AID] => 3
[Sites] => Array
(
[0] => 4 //SiteID
)
)
[2] => Array
(
[AID] => 4
[Sites] => Array
(
[0] => 1 //SiteID
)
)
)
我用这段代码试试:
public function createListOfCorpOwnedSites()
{
foreach ($this->combined as &$site) {
$aids = array();
foreach ($this->result_array as $acct) {
if ($acct['SiteID'] === $site['SiteID'])
$aids[] = $acct['AID'];
}
$site['CorpAID'] = $aids;
}
print_r($this->combined );
}
但是,我需要一个更好的结果,第一个,我需要添加指向由多个 AID 拥有的 SiteID 列表的 CorpAID 的键。
结果应该是这样的:
Array([0]=> Array(
[SiteID] => 1
[Balance] => 2000
[MinBalance] => 1000
[MaxBalance] => 500
[OwnerAID] => 1
[GroupID] => 1
[Deposit] => 10000
[Reload] => 0
[Redemption] => 0
[CorpAID] => Array(
[0] => 1
[1] => 4
)
有可能做到吗?请以正确的方式指导我,感谢您的关注,并提前感谢您。