【发布时间】:2013-03-04 21:59:05
【问题描述】:
我正在使用脚本来创建额外的表单行。 它为某些文本字段循环 $i 数字 当我运行这个脚本时,偏移量是未定义的,因为它不存在。 我需要使用 if(isset()) 函数,但我不确定如何将它放在代码中。 有人可以帮忙吗?
for ($i=0; $i<100; $i++) {
if ($text['length'][$i] == "") $text['length'][$i] = "0";
if ($text['bredth'][$i] == "") $text['bredth'][$i] = "0";
if ($text['height'][$i] == "") $text['height'][$i] = "0";
if ($text['weight'][$i] == "") $text['weight'][$i] = "0.00";
所有以'if'开头的行都显示通知:
注意:未定义的偏移量:C:\xampp\htdocs\newparcelscript.php 第 41 行中的 1
已解决 事实上,我根本不需要和“if”语句,因为行的创建和值的设置是一起运行的。
for ($i=0; $i<100; $i++) {
$text['length'][$i] = "0";
$text['breadth'][$i] = "0";
$text['height'][$i] = "0";
$text['weight'][$i] = "0.00";
【问题讨论】:
-
我建议试试 $text[$i]['weight']
-
很高兴我能帮上忙 ;)
标签: php loops undefined offset