现有a.html表单内里有这样的内容
<input name="productbrand1" type="text" size="8">
<input name="productbrand2" type="text" size="8">
<input name="productbrand3" type="text" size="8">
<input name="productbrand4" type="text" size="8">
<input name="productbrand16" type="text" size="8">
<input name="hotbrand1" type="text" size="8">
<input name="hotbrand2" type="text" size="8">
<input name="hotbrand3" type="text" size="8">
<input name="hotbrand4" type="text" size="8">
<input name="hotbrand5" type="text" size="8">
我想提交表单接收值
把productbrand名字和hotbrand名字的所有值分别组合成一个字符串,用“,”隔开。
例如:$productbrand="23,54,76,25..."如何循环接受productbrand的值,在用“,”分隔,组合成一个字符串,或者其他方法。
<input name="productbrand1" type="text" size="8">
<input name="productbrand2" type="text" size="8">
<input name="productbrand3" type="text" size="8">
<input name="productbrand4" type="text" size="8">
<input name="productbrand16" type="text" size="8">
<input name="hotbrand1" type="text" size="8">
<input name="hotbrand2" type="text" size="8">
<input name="hotbrand3" type="text" size="8">
<input name="hotbrand4" type="text" size="8">
<input name="hotbrand5" type="text" size="8">
我想提交表单接收值
把productbrand名字和hotbrand名字的所有值分别组合成一个字符串,用“,”隔开。
例如:$productbrand="23,54,76,25..."如何循环接受productbrand的值,在用“,”分隔,组合成一个字符串,或者其他方法。
$a ='';
$b ='';
foreach($_POST as $k=>$v){
if(preg_match('/productbrand\d+/i',$k)){
$a .= $v . "," ;
}
if(preg_match('/hotbrand\d+/i',$k)){
$b .= $v . "," ;
}
}
$a = substr($a , 0 ,-1);
$b = substr($b , 0 ,-1);