POST在传递数字的时候能不能传递一个数组的值,比如
<input type="text" name="hidden" value="<?php echo $rows->id ?>">
其中<?php echo $rows->id ?>是循环数组得到的值,那么在POST传递到下一个页面的时候能不能将数组的值都传下去而不是只是第一个值,我目前的状况就是就传递了第一个元素的值。高手帮忙!
<input type="text" name="hidden" value="<?php echo $rows->id ?>">
其中<?php echo $rows->id ?>是循环数组得到的值,那么在POST传递到下一个页面的时候能不能将数组的值都传下去而不是只是第一个值,我目前的状况就是就传递了第一个元素的值。高手帮忙!
$arr 就是一个数组来的了。
$hidden = json_decode(base64_decode($_POST['hidden ']),true);
Array
(
[0] => 1
[1] => 2
[2] => 3
)
有什么问题的么?(你应该是生成html代码的时候有点问题的吧!楼上说的都是对的啊)
index文件代码如下:
<form id="test1" method="post" action="postTest2.php" >
<input type="text" name="hidden[]" value="<?php echo "1"; ?>">
<input type="text" name="hidden[]" value="<?php echo "2"; ?>">
<input type="text" name="hidden[]" value="<?php echo "3"; ?>">
<input type="submit" value="button">
</form>postTest2.php代码如下:
<?php
print_r($_POST['hidden']);
?>