I have two arrays.
ArrayA is numeric
(ArrayA => 3, 7, 8)
ArrayB is an associative array
(1=>bread, 2=>banana, 3=>fruit, 4=> milk, 5=>pizza, 6=> gum, 7=>corn, 8=>lager)
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.
In other words, from this example
ArrayC (3 => fruit, 7=>corn, 8=>lager)
However my code is only giving me
ArrayC (3 => lager, 7=>lager, 8=>lager) //last value of ArrayB
Code:
     $ArrayC = array();
     foreach ($ArrayB as $keyB => $valueB) {
          foreach ($ArrayA as $valueA) {
             if ( $valueA = $keyB) {
                   $ArrayC [$valueA] = $valueB;
             }
          }
      }
      print_r($ArrayC);
 
     
     
     
     
     
     
    