0
我正在为Zen Cart的模块编写一些代码。 $ stores_id是含3个值的数组:for循环没有回应我的数组中的期望值
$stores_id[0]="1";
$stores_id[1]="2";
$stores_id[2]="3";
用下面的代码我试图回波隐藏的输入字段,填充数据从阵列
for ($i=0, $n=sizeof($stores_id); $i<$n; $i++)
{
echo zen_draw_hidden_field('stores_id['. $stores_id[$i]['stores_id'] .']', htmlspecialchars(stripslashes($stores_id[$stores_id[$i]['stores_id']]), ENT_COMPAT, CHARSET, TRUE));
}
回送的结果是:
<input type="hidden" value="2" name="stores_id[1]">
<input type="hidden" value="3" name="stores_id[2]">
<input type="hidden" name="stores_id[3]">
,而我希望它是:
<input type="hidden" value="1" name="stores_id[1]">
<input type="hidden" value="2" name="stores_id[2]">
<input type="hidden" value="3" name="stores_id[3]">
谁能告诉我我做错了什么?
谢谢你,那确实起作用。我使用了第一个选项,因为在正常的操作中,数组可以用任意值的组合填充,然后第二个选项不起作用。 – Zen4All
通过删除'['stores_id']'来进一步简化代码。 现在回显线为: 'echo zen_draw_hidden_field('stores_id ['。$ stores_id [$ i]。']',htmlspecialchars(stripslashes($ stores_id [$ i]),ENT_COMPAT,CHARSET,TRUE));'' – Zen4All