我想用这样一段代码,让表单直接提交一个数组<form method="post" action="content.php">
$cou[0]="id";<br/>
$cou[1]="title";<br/>
$cou[2]="hours";<br/>
<input type="checkbox" name="name" value="$cou"/></form>我以为这样当我check这个box时,在下一页content.php,使用
$_POST["name"]我就可以得到整个数组
但是我得到的只是Array,这么个词。是不是php不能这么用的?
$cou[0]="id";<br/>
$cou[1]="title";<br/>
$cou[2]="hours";<br/>
<input type="checkbox" name="name" value="$cou"/></form>我以为这样当我check这个box时,在下一页content.php,使用
$_POST["name"]我就可以得到整个数组
但是我得到的只是Array,这么个词。是不是php不能这么用的?
<input type="hidden" name="cou[]" value="id">
<input type="hidden" name="cou[]" value="title">
<input type="hidden" name="cou[]" value="hours">
</form>content.php
print_r($_POST['cou']);看我的方法改造.
CON8101 Residential Building/Estimating 5 Fall O
CON8411 Construction Materials I 3 Fall O
CON8430 Computers and You 3 Fall O
CST8258 Web Project Management 3 Fall O
CST8259 Web Programming Languages II 4 Fall O上面,每个checkbox都需要返回好几个不同类型的值,而你的例子每个checkbox只管理一个
单独的值。所以我就不知道该怎么返回了。
$Str=array ('Id'=>1,'Name'=>'Small Brother','Size'=>'6CM');
$Str=serialize($Str);
//输出
echo '<input name="MySize" type="hidden" value="'.$Str.'">"'; //接收页面
$Str=unserialize($_POST['Mysize']);
将值序列化
$cou[0]="id";
$cou[1]="title";
$cou[2]="hours";
$str=serialize($str);
?>
<input type="checkbox" name="name" value="$str"/></form>
content.php$arr=unserialize($_POST['name']);
print_r($arr);