title: foreach loop only repeating last array value
body: <p>I have two arrays.</p>
  
  <p>ArrayA is numeric </p>
  
  <pre><code>(ArrayA =&gt; 3, 7, 8)
  </code></pre>
  
  <p>ArrayB is an associative array </p>
  
  <pre><code>(1=&gt;bread, 2=&gt;banana, 3=&gt;fruit, 4=&gt; milk, 5=&gt;pizza, 6=&gt; gum, 7=&gt;corn, 8=&gt;lager)
  </code></pre>
  
  <p>I want to create a third array, ArrayC, associative, that matches the Values of ArrayA with ArrayB keys, and gives ArrayA keys the relevant ArrayB values.</p>
  
  <p>In other words, from this example </p>
  
  <pre><code>ArrayC (3 =&gt; fruit, 7=&gt;corn, 8=&gt;lager)
  </code></pre>
  
  <p>However my code is only giving me</p>
  
  <pre><code>ArrayC (3 =&gt; lager, 7=&gt;lager, 8=&gt;lager) //last value of ArrayB
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>     $ArrayC = array();
       foreach ($ArrayB as $keyB =&gt; $valueB) {
            foreach ($ArrayA as $valueA) {
               if ( $valueA = $keyB) {
                     $ArrayC [$valueA] = $valueB;
               }
            }
        }
        print_r($ArrayC);
  </code></pre>