我有以下 HTML:
<input type="checkbox" name="plusfri[]" value="Fri"> Friday
<input type="checkbox" name="plussat[]" value="Sat"> Saturday
<input type="checkbox" name="plussun[]" value="Sun"> Sunday
<input type="checkbox" name="plusmon[]" value="Mon"> Monday
该帖子发布到以下PHP:
$plus = array(array("Name" => "", "Days" => "", "Age" => "","Conc" => ""));
foreach($_POST['plusname'] as $k => $p)
{
$plus[$k]['Name'] = $p;
$plus[$k]['Age'] = $_POST['plusage'][$k];
$plus[$k]['Conc'] = $_POST['plusconc'][$k];
$plus[$k]['Days'] = "X";
if($_POST['plusfri'][$k]=="Fri") $plus[$k]['Days'] .= "1";
if($_POST['plussat'][$k]=="Sat") $plus[$k]['Days'] .= "2";
if($_POST['plussun'][$k]=="Sun") $plus[$k]['Days'] .= "3";
if($_POST['plusmon'][$k]=="Mon") $plus[$k]['Days'] .= "4";
}
我最终得到:
array(3) {
[0]=>
array(4) {
["Name"]=>
string(6) "FRISAT"
["Days"]=>
string(3) "X12"
["Age"]=>
string(1) "1"
["Conc"]=>
string(0) ""
}
[1]=>
array(4) {
["Name"]=>
string(6) "SATSUn"
["Age"]=>
string(1) "1"
["Conc"]=>
string(0) ""
["Days"]=>
string(3) "X23"
}
[2]=>
array(4) {
["Name"]=>
string(6) "SUNMON"
["Age"]=>
string(1) "1"
["Conc"]=>
string(0) ""
["Days"]=>
string(3) "X34"
}
}
谁能告诉我为什么“Days”只在元素 [1] 和 [2] 上跳到最后??>