我有以下代码:
foreach ($model_name as $md) {
foreach ($years as $y) {
$model_w_year[$y] = $md;
}
}
这显然不起作用。它输出的数组如下所示:
Array
(
[1994] => Maxima
[1995-1998] => Maxima
)
我希望它看起来像这样:
Array
(
[1994] => Sentra
[1995-1998] => Maxima
)
Model_name 是上一页的 $_SESSION['model_name'] ,years 是表单数组
echo "<form action='engine.php' method='post'>";
for ($i = 0; $i < count($model_name); $i++) {
echo "Enter year or year range for: ", $model_name[$i],
" <input type='text' name='years[]'></input><br />";
}
这是我拥有的所有数组结构:
Model make:
Nissan
model name:
Array
(
[0] => Sentra
[1] => Maxima
)
Number of models:
2
Number of years:
Array
(
[0] => 1994
[1] => 1995-1998
)
Model with Year:
Array
(
[1994] => Maxima
[1995-1998] => Maxima
)
答:是的,我希望年份是关键,模型是价值。