【发布时间】:2021-06-20 00:35:02
【问题描述】:
首先我像这样将数据发送到控制器
[Product_Id] => 11
[selected_Product_Id] => ASIN
[Product_Name] => 22
[Brand_Name] => 33
[Country_Of_Origin] => India
[Product_Length] => 44
[selected_Product_Length] => Angstrom
[Product_Width] => 55
[selected_Product_Width] => Angstrom
[Product_Height] => 66
[selected_Product_Height] => Angstrom
[Number_of_Pieces] => 77
[Included_Components] => 88
[Assembly_Instruction] => 99
[Size] => 10
[Wood_Type] => 20
然后在后端存储我使用的数据
foreach($_POST as $key => $value){
$name = str_replace('_', ' ', $key);
$replace_name = str_replace('_', ' ', $key) ."=".$value. '<br />' ;
echo $replace_name.<br />;
//if(strpos($name, 'selected') !== false){
//$select_name = str_replace('selected', '', $name);
//echo $select_name.'='.$value.'<br />';
//}else{
//echo $replace_name;
//}
// if (preg_match('/\b'.$select_name.'\b/', $name)) {
// echo $name ;
// }
}
我得到的数据在这里
产品 ID=11
选择的产品 ID=ASIN
产品名称=22
品牌名称=33
原产国=印度
产品长度=44
选择的产品长度=埃
产品宽度=55
选择的产品宽度=埃
产品高度=66
选择的产品高度=埃
件数=77
包含的组件=88
组装说明=99
尺寸=10
木型=20
但我想要这样
产品 ID=11 ASIN
产品名称=22
品牌名称=33
原产国=印度
产品长度=44 埃
产品宽度=55 埃
产品高度=66 埃
件数=77
包含的组件=88
组装说明=99
尺寸=10
木材类型=20
对不起,我的简短解释我不知道如何解释,但如果我有一个带有选择标签的输入,我希望输入名称为例如产品宽度 = 22 + 选择我在后英寸中获得的标签选项值,如产品宽度 = 22 英寸
当我得到上述数据后,需要将数据转换成这样的数组
array(
[Product_Id] => 11 ASIN
[Product_Name] => 22
[Brand_Name] => 33
[Country_Of_Origin] => India
[Product_Length] => 44 Angstrom
[Product_Width] => 55 Angstrom
[Product_Height] => 66 Angstrom
[Number_of_Pieces] => 77
[Included_Components] => 88
[Assembly_Instruction] => 99
[Size] => 10
[Wood_Type] => 20
)
【问题讨论】:
标签: php