text: Q:
  
  Select array values based on another array
  
  I have 2 arrays :  “Array-List” and “Array-Criteria” :
  Array-List
  (
      [1] => APPLE
      [2] => BANANA
      [3] => ORANGE
      [4] => LEMON
  )
  
  Array-Criteria
  (
      [0] => 1
      [1] => 3
  )
  
  Is there a quick way (my Array-List can consist of thousands of entries) to select the values from Array-List based on Array-Criteria without looping through Array-List in PHP?
  
  A:
  
  Use array_intersect_key and array_flip functions to get data as:
  $arr1 = Array-List
  (
      [1] => APPLE
      [2] => BANANA
      [3] => ORANGE
      [4] => LEMON
  )
  
  $arr2 = Array-Criteria
  (
      [0] => 1
      [1] => 3
  )
  
  var_dump(array_intersect_key($arr1, array_flip($arr2)));
  
  