title: PHP - How to map elements of one array as keys to another array and return resulting values as an array?
body: <p>This should be an easy one liner, but I can't quite get it:</p>
  
  <p>I have an array like this:</p>
  
  <pre><code>$a = ["z", "x", "y"];
  </code></pre>
  
  <p>and an array like this:</p>
  
  <pre><code>$b = ["x"=&gt;"a", "y"=&gt;"b", "z"=&gt;"c"];
  </code></pre>
  
  <p>what is a php oneliner to get:</p>
  
  <pre><code>$c = ["c", "a", "b"];
  </code></pre>
  
  <p>I want to use each element of a to index into b and return an array of the results
  I've been looking at array_map but couldn't figure out how to bind b to the callback function.  I'm still new to PHP, thanks!</p>
  
  <p>BTW, I did some searching for this, but couldn't find exactly what I was looking for.</p>
  
  <p>ADDITIONAL INFO (EDITED):</p>
  
  <p>This is what I was trying, and the syntax I want:</p>
  
  <pre><code>$c = array_map(function($key) use ($b){ return $b[$key]; }, $a); 
  </code></pre>
  
  <p>MORE ADDITIONAL INFO:</p>
  
  <p>It appears the 'use' keyword is used to bind functions to closures.</p>
  
  <p><a href="http://www.php.net/manual/en/functions.anonymous.php" rel="nofollow">http://www.php.net/manual/en/functions.anonymous.php</a></p>