2
我正在使用帶有複選框的表單。下面是部分代碼:
if(isset($_POST['send'])){
$grandezas = array('tempCheckbox', "umiCheckbox", "uvCheckbox", "ventoCheckbox", "direcaoventoCheckbox", "precipitacaoCheckbox");
$grandezasCount = 0;
$tamanhoArray = count($grandezas);
for($i = 1; $i <= $tamanhoArray; $i++){
if($_POST[$grandezas[i]])
$grandezasCount++;
echo $grandezas[i]."."; // This gives me null values.
}
echo "<br>".count($grandezas)."<br>";
echo $grandezasCount;
printf("%s", $grandezas[1]);
我有$grandezas
陣列我在表單中使用的複選框的名字(已經被選中,他們是正確的)。檢查時它們返回值1。所有其他的形式都可以用類似的邏輯完美地工作。
當我使用:
echo "<br>".count($grandezas)."<br>";
printf("%s", $grandezas[1]);
它的工作原理正確,但內裏的回聲for循環不斷給我空值。
我在使用$_POST[$grandezas[i]]
錯誤的方式嗎?
哦,我的上帝......感謝您的幫助。我是PHP新手,我經常忘記這種東西...... – George