用PHP表单传递数组
test.php
formmethod="post" action="test2.php">
<input name="a[]" value="1" />
<input name="a[]" value="2" />
<input name="a[]" value="3" />
<input type="submit"
</form>
test2.php
<?php
print_r($_POST['a']);
?>
结果:
Array( [0] => 1 [1] => 2 [2]=> 3 )
test.php
formmethod="post" action="test2.php">
<input name="a[4]" value="1" />
<input name="a[5]" value="2" />
<input name="a[6]" value="3" />
<input type="submit"
</form>
test2.php
<?php
print_r($_POST['a']);
?>
结果:
Array( [4] => 1 [5] => 2 [6]=> 3 )
test.php
formmethod="post" action="test2.php">
<input name="a[11]" value="1"/>
<input name="a[22]" value="2"/>
<input name="a[33]" value="3"/>
<input type="submit"
</form>
test2.php
<?php
print_r($_POST['a']);
?>
结果:
Array( [11] => 1 [22] => 2 [33]=> 3 )