fork download
  1. <?php
  2.  
  3. // your code goes here
  4.  
  5. $arr = array(1 => 'bar', 2 => 'bin', 3 => 'ipsum', 4 =>'hz');
  6. $foundUnicIds = array(2, 4);
  7.  
  8. $intersect = array_intersect_key($arr, array_flip($foundUnicIds));
  9. $result = array_values($intersect);
  10.  
  11. print_r($result);
Success #stdin #stdout 0s 82560KB
stdin
Standard input is empty
stdout
Array
(
    [0] => bin
    [1] => hz
)