tags:

views:

90

answers:

1

I have an 'dictionary' array such as this:

  $arr['a']=5;
  $arr['b']=9;
  $arr['as']=56;
  $arr['gbsdfg']=89;

And I need a method that, given a list of the array keys, I can retrieve the corresponding array values. In other words, I am looking for a built-in function for the following methods:

function GetArrayValues($arrDictionary, $arrKeys)
{
  $arrValues=array();
  foreach($arrKeys as $key=>$value)
  {
     $arrValues[]=$arrDictionary[$key]
  }
  return $arrValues;
}

I am so sick of writing this kind of tedious transformation that I have to find a built-in method to do this. Any ideas?

+6  A: 

array_intersect_key

Fragsworth
Short and to the point, I like that.
Tom