Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我可以在php的请求参数中传递一个数组吗
例如
我这里有一个隐藏的提交表单
<form action="" method="POST"><input type="hidden" name="myarray" value="' . $arrayofvalues . '">
然后我可以这样调用正确的变量吗?
($_REQUEST['arrayofvalues[1]'] ($_REQUEST['arrayofvalues[2]']
是的。只需在输入名称属性中使用 PHP 数组语法:
<input type="hidden" name="myarray[]" value="<?php echo $_REQUEST['myarray'][0]; ?>"> <input type="hidden" name="myarray[]" value="<?php echo $_REQUEST['myarray'][1]; ?>">
在 PHP 中:
print_r($_REQUEST['myarray']);