我的代碼如下的foreach循環:複製輸出錯誤
$aNewCodes = array("93", "355", "213");
$aServiceProviderId = array();
$oTerminationRate = new TerminationRate();
foreach ($aNewCodes as $iNewCodesKey => $iNewCodesValue)
{
$oTerminationRate->GetServiceProviders($aServiceProviderId, $iNewCodesValue);
foreach($aServiceProviderId as $iProviderKey => $iProviderValue)
{
echo $iNewCodesValue." :: ".$iProviderValue."<br>";
}
}
,這讓我輸出這樣的 -
93 :: 1
93 :: 2
355 :: 1
355 :: 2
355 :: 1
355 :: 2
213 :: 1
213 :: 2
213 :: 1
213 :: 2
213 :: 1
213 :: 2
其實我期待輸出這樣的 -
93 :: 1
93 :: 2
355 :: 1
355 :: 2
213 :: 1
213 :: 2
嘗試了很多以獲得該輸出,但沒有成功。我錯過了什麼地方?
您可能錯過了「GetServiceProviders'通過引用*接受其第一個參數*的部分,並向其中添加了兩個項目。如果沒有,你的代碼不會給任何*輸出。 – Jon 2012-04-17 10:34:54
是的,它通過引用接受,並且代碼確實給出了輸出結果。 – skos 2012-04-17 10:37:21