Organizational Research By

Surprising Reserch Topic

Question:To find the keys that are in 2 arrays, without caring of the values using php?



asked Sep 13, 2013 in PHP by rajesh
edited Sep 12, 2013
+1 vote
18 views



Related Hot Questions

1 Answer

0 votes

To find the keys that are in 2 arrays, without caring of the valuesThis is a function i needed, and it also returns the values of the first array

 
function array_key_intersect(&$a, &$b) {
  $array = array();
  while (list($key,$value) = each($a)) {
    if (isset($b[$key]))
      $array[$key] = $value;
  }
  return $array;
}
?>
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013

...