title: Replace one arrays keys with another arrays values in php
body: <p>I want to map form fields to database fields.</p>
  
  <p>I have two arrays..</p>
  
  <p>One array is the <strong>data</strong> and contains the form field id as the key and the form field value as the value.</p>
  
  <pre><code>$data = array("inputEmail"=&gt;"someone@somewhere.com","inputName"=&gt;"someone"... etc
  </code></pre>
  
  <p>I also have an array which i intended to use as a <strong>map.</strong> The keys of this array are the same as the form fields and the values are the database field names.</p>
  
  <pre><code>$map = array("inputEmail"=&gt;"email", "inputName"=&gt;"name"... etc
  </code></pre>
  
  <p>What i want to do is iterate over the data array and where the data key matches the map key assign a new key to the data array which is the value of the map array.</p>
  
  <pre><code>$newArray = array("email"=&gt;"someone@somewhere.com", "name"=&gt;"someone"...etc
  </code></pre>
  
  <p>My question is how? Ive tried so many different ways im now totally lost in it.</p>