This is my array in PHP:
$arr['key1']='value1';
$arr['key2']='value2';
$arr['key3']='value3';
$arr['key4']='value4';
$arr['key5']='value5';
$arr['key6']='value6';
I would like to test if a key is in the array. Is this function the correct way to proceed?
function isKeyInArray($key, $arr) {
if(isset($arr[$key]))
return true;
else
return false;
}
What I expect is that:
isKeyInArray('key3', $arr) // return true
isKeyInArray('key9', $arr) // return false
Many thanks in advance.
array_key_exists()?