title: Changing all Keys of an Array
body: <p>I have an array called <code>$row</code>: </p>
  
  <pre><code>$row = array(
      "comments" =&gt; "this is a test comment", 
      "current_path" =&gt; "testpath"
  )
  </code></pre>
  
  <p>I have another array called <code>$dictionary</code>: </p>
  
  <pre><code>$dictionary= array(
      "comments" =&gt; "comments", 
      "current_directory" =&gt; "current_path"
  )
  </code></pre>
  
  <p>I want to change the keys in <code>$row</code> to the key associated with the matching value in <code>$dictionary</code>. </p>
  
  <p>For example, in the case above, <code>$row</code> would become: </p>
  
  <pre><code>$row = array(
      "comments" =&gt; "this is a test comment", 
      "current_directory" =&gt; "testpath"
  )
  </code></pre>
  
  <p>I have tried using <code>array_map</code> but this doesn't seem to be changing anything:</p>
  
  <pre><code>array_map(function($key) use ($dictionary){
    return array_search($key, $dictionary);
  }, array_keys($row)); 
  </code></pre>
  
  <p>How would I change the key properly?</p>
  
  <p>Note from comment:</p>
  
  <blockquote>
    <p>Unfortunately, there will generally be more entries in $dictionary then $row and the order cannot be guaranteed</p>
  </blockquote>