You are here

function _autoassignrole_array_intersect_key in Auto Assign Role 5

Same name and namespace in other branches
  1. 5.2 autoassignrole.module \_autoassignrole_array_intersect_key()
  2. 6.2 autoassignrole.module \_autoassignrole_array_intersect_key()
  3. 6 autoassignrole.module \_autoassignrole_array_intersect_key()
1 call to _autoassignrole_array_intersect_key()
_autoassignrole_intersect in ./autoassignrole.module

File

./autoassignrole.module, line 274

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;
  }
}