You are here

function _autoassignrole_array_intersect_key in Auto Assign Role 6.2

Same name and namespace in other branches
  1. 5.2 autoassignrole.module \_autoassignrole_array_intersect_key()
  2. 5 autoassignrole.module \_autoassignrole_array_intersect_key()
  3. 6 autoassignrole.module \_autoassignrole_array_intersect_key()

File

./autoassignrole.module, line 383
The main autoassignrole.module file

Code

function _autoassignrole_array_intersect_key($isec, $keys) {
  $argc = func_num_args();
  if ($argc > 2) {
    for ($i = 1; !empty($isec) && $i < $argc; $i++) {
      $arr = func_get_arg($i);
      foreach (array_keys($isec) as $key) {
        if (!isset($arr[$key])) {
          unset($isec[$key]);
        }
      }
    }
    return $isec;
  }
  else {
    $res = array();
    foreach (array_keys($isec) as $key) {
      if (isset($keys[$key])) {
        $res[$key] = t($isec[$key]);
      }
    }
    return $res;
  }
}