You need to do the is_array() test before the array_key_exists() test.Also, the arg for is_array(should just be the array variable name -- no array index. You can just swap the order in your code, or nest them in order to better indicate what happens on each call.
function check_exist($key,$arr){
if(is_array($arr)) {
if(array_key_exists($key, $arr)
return mysql_real_escape_string(mb_strtolower($arr[$key]));
}else{
return NULL;
}
} else {
$err = debug_backtrace();
user_error("<pre>".print_r($err, 1)."</pre>");
return false;
}
}
Alternatively, if using PHP 5.3 or later and if you do not need to support older versions, you can use type-hinting (which will throw an exception if the type is not valid):
function check_exist($key, [B][COLOR="Red"]array[/COLOR][/B] $arr) {