foreach($notZeroValue as $cardSetPosition => $timesChosen){
echo $groupValue;
$notZeroValue[$cardSetPosition + ($groupValue*100)] = $notZeroValue[$cardSetPosition];
unset ($notZeroValue[$cardSetPosition]);
}
輸出爲0000
(正確的,因爲$notZeroValue
具有四個元件和爲每一個$groupValue = 0
)改變在陣列變量的鍵值與Foreach循環
我知道必須有一個新手錯誤,因爲改變*100
到+100
產生關鍵值101
,102
,103
,104
。
print_r($notZeroValue); //output = array()
那麼你遇到的問題是什麼? – jprofitt
我認爲你必須提供更多信息。 $ groupValue'定義在哪裏?陣列是什麼樣的?你得到的結果是什麼,你期望的結果是什麼? –