Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 具有可变输入值的表单_Php_Forms - Fatal编程技术网

Php 具有可变输入值的表单

Php 具有可变输入值的表单,php,forms,Php,Forms,我有一个表单,它有可变的输入值。例如,一个客户买了5件商品,所以所有这些都显示另一个客户买了3件商品,所以只显示了3件商品。所有这些值都基于数据库 <form id="customer" class="customer" method="post" action=""> <input type="text" name="customer1" value="" > <input type="text" name="customer2" value="

我有一个表单,它有可变的输入值。例如,一个客户买了5件商品,所以所有这些都显示另一个客户买了3件商品,所以只显示了3件商品。所有这些值都基于数据库

<form id="customer" class="customer" method="post" action="">
    <input type="text" name="customer1" value="" > 
    <input type="text" name="customer2" value="" > 
    <input type="text" name="customer3" value="" > 
</form>

现在我的问题是,每次post变量的数量不同时,如何处理这样的表单。

类似于:

$products = array();
foreach ($_POST as $key => $value) {
    array_push($products, $key, $value);
}

谢谢,我明白了,谢谢你的帮助。