<?php
/* A Function created by myself for checking multiple array keys
For Example u got an Array like $_SESSION and u wanna know if the keys 'user','pass','email' and 'type' exists.
*/
function mKeyChecker($arr,$keys=array()) {
if(count($keys) > 1) {
$valid_keys = 0;
foreach($keys as $key) {
if(array_key_exists($key,$arr)) $valid_keys++;
}
if($valid_keys == count($keys)) {
return true;
} else {
return false;
}
} else if(count($keys) == 1) {
if(array_key_exists($key[0],$arr)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
// Execution Example
if(mKeyChecker($_SESSION,array('id','user','email','type'))) {
echo "is!";
} else {
echo "not!";
}
?>