My Arrray Value is Overwritten in nested foreach loop
<p>I have the following code:</p>

<pre><code>foreach ($model_name as $md) {
    foreach ($years as $y) {
        $model_w_year[$y] = $md;
    } 
}
</code></pre>

<p>It's obviously not working. The array it outputs looks like like:</p>

<pre><code>Array
(
    [1994] =&gt; Maxima
    [1995-1998] =&gt; Maxima
)
</code></pre>

<p>I want it to look like this:</p>

<pre><code>Array
(
    [1994] =&gt; Sentra
    [1995-1998] =&gt; Maxima
)
</code></pre>

<p>Model_name is a $_SESSION['model_name'] from previous page and years is a form array</p>

<pre><code>echo "&lt;form action='engine.php' method='post'&gt;";
for ($i = 0; $i &lt; count($model_name); $i++) {
   echo "Enter year or year range for: ", $model_name[$i], 
       " &lt;input type='text' name='years[]'&gt;&lt;/input&gt;&lt;br /&gt;";
}
</code></pre>

<p>And here are all array structures that I have:</p>

<pre><code>Model make: 
Nissan
model name: 
Array
(
    [0] =&gt; Sentra
    [1] =&gt; Maxima
)

Number of models:  
2
Number of years: 
Array
(
    [0] =&gt; 1994
    [1] =&gt; 1995-1998
)

Model with Year: 
Array
(
    [1994] =&gt; Maxima
    [1995-1998] =&gt; Maxima
)
</code></pre>

<p>Answer: yes I want the year to be the key and the model to be the value.</p>
