嗨我从post使用serialize函数得到的值显示错误的值。它只显示N ..请帮助我
Php Code
$item_select_alpha = $_POST['item_select_alpha'];
for ($alpha = 1; $alpha <= count($item_select_alpha); $alpha++) {
$serialise = serialize(array($item_select_alpha[$alpha]));
}
$item_quanity = $_POST['item_quanity'];
for ($qty = 1; $qty <= sizeof($item_quanity); $qty++) {
$item_quan = serialize($item_quanity[$qty]);
}
print_r($item_quan);
exit;
HTML代码
<select class="item_select_alpha" name="item_select_alpha[]">
<option value="">select the Alphabetic</option>
{foreach $size_alpha as $sa}
<option value="{$sa['size_id']}">{$sa['size_name']}</option>
{/foreach}
</select>
<input type="text" class="item_quanity" name="item_quanity[]" class="form-control">
答案 0 :(得分:0)
for循环中的变量将只包含最后一个元素,在每次迭代时更新它们的值。在第二个循环中定义的$ item_quan不会是&#34;可打印&#34;离开了...
答案 1 :(得分:0)
您不能向数组添加项目,只会更改变量,使其包含最后一个元素。试试这个:
$serialise[] = serialize(array($item_select_alpha[$alpha]));
$item_quan[] = serialize($item_quanity[$qty]);