title: Combine 2 arrays of different length
body: <p>I have an array with 100 values(array1). I have another array with 8 values(array2). I want to take the values from array2 and use them as keys and extract the values in array1 for those keys. </p>
  
  <p>The array_combine function won't work as they are of different lengths. </p>
  
  <p>I have tried </p>
  
  <pre><code>function array_combine2($arr1, $arr2) {
      $count = min(count($arr1), count($arr2));
      return array_combine(array_slice($arr1, 0, $count), array_slice($arr2, 0, $count));
  }
  </code></pre>
  
  <p>But this doesn't work.....this gives me an array with the correct keys, but the values are incorrect, I think because it is slicing array1. </p>
  
  <p>Could someone give some assistance. There is a fair amount of literature on this already, I know, but they all give solutions very similar to the one above which isn't working. </p>
  
  <p>Many thanks for the time you have taken. </p>