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'定义在哪里?阵列是什么样的?你得到的结果是什么,你期望的结果是什么? –