php - PHP 多文本框数组 POST
问题描述
<form method="post">
<?php
for($i = 1; $i <= 1000; $i++)
{
for($j = 1; $j <= 100; $j++)
{
echo "<input type=\"text\" name=\"text" . $j . "[]\" value=\"" . ($i * $j) . "\" />";
}
}
?>
<input type="submit" />
</form>
为什么发布 1000 行时只输出 10 行?php.ini
已经在like input_max_var
,max_execution_time
等中设置了所有变量max_post_limit
...
输出
Array
(
[text1] => Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
[9] => 10
)
[text2] => Array
(
[0] => 2
[1] => 4
[2] => 6
[3] => 8
[4] => 10
[5] => 12
[6] => 14
[7] => 16
[8] => 18
[9] => 20
)
.
.
.
[text100] => Array
(
[0] => 100
[1] => 200
[2] => 300
[3] => 400
[4] => 500
[5] => 600
[6] => 700
[7] => 800
[8] => 900
[9] => 1000
)
)
memory_limit = -1
post_max_size = 1G
max_execution_time = -1
max_input_time = -1
max_input_vars = -1
suhosin.post.max_vars = -1
suhosin.request.max_vars = -1
解决方案
因此,您在页面上有 100 000 个输入,但它们的名称无效 - 页面上有重复项。它应该是$i
和$j
<form method="post">
<?php
for($i = 1; $i <= 1000; $i++)
{
for($j = 1; $j <= 100; $j++)
{
echo "<input type=\"text\" name=\"text" . ($j * $i) . "[]\" value=\"" . ($i * $j) . "\" />";
}
}
?>
<input type="submit" />
</form>
推荐阅读
- r - R:如何为数据框中的子集行申请循环
- c++ - 处理除以零
导致意外行为 - reactjs - 如何使 React.Children.map 与 Typescript 一起使用?
- python - 通过 Snakemake 进行符号链接(自动生成)目录
- python - 我使用熊猫附加到 DataFrame 的数据(数字)
- sql - 设计具有良好数据结构的调查构建器?
- reactjs - 具有 Redux 集成的 ag-Grid 服务器端行模型
- swift - unwind segue 冻结 UI
- rest - 刷新从 HTTP 请求中提取的 SwiftUI 视图中的数据
- c++ - Visual Studio 不更新项目内的文件夹