将相关的表单字段分隔为多维数组

时间:2021-03-09 15:57:00

Is it possible to create a multidimensional $_POST array that contains related fields? (CompanyName, CompanyAddress, CompanyPhone) (HomePhone, HomeAddress, HomeState) What I would like to do is when I click submit I essentially have two arrays inside of the $_POST array like this:

是否可以创建包含相关字段的多维$ _POST数组? (CompanyName,CompanyAddress,CompanyPhone)(HomePhone,HomeAddress,HomeState)我想要做的是当我点击提交时,我基本上在$ _POST数组中有两个数组,如下所示:

   $_POST['CompanyInfo']['CompanyName']
   $_POST['CompanyInfo']['CompanyAddress'] 
   $_POST['CompanyInfo']['CompanyPhone'] 

   $_POST['HomeInfo']['HomePhone']
   $_POST['HomeInfo']['HomeState']
   $_POST['HomeInfo']['HomeAddress']

1 个解决方案

#1


0  

Setting up your form's input names properly will allow you to accomplish this.

正确设置表单的输入名称将允许您完成此操作。

Consider <input name="CompanyInfo[CompanyName]" type="text" /> could be accessed with $_POST['CompanyInfo']['CompanyName']

考虑可以使用$ _POST ['CompanyInfo'] ['CompanyName']访问

#1


0  

Setting up your form's input names properly will allow you to accomplish this.

正确设置表单的输入名称将允许您完成此操作。

Consider <input name="CompanyInfo[CompanyName]" type="text" /> could be accessed with $_POST['CompanyInfo']['CompanyName']

考虑可以使用$ _POST ['CompanyInfo'] ['CompanyName']访问