Check if a key exists and get a corresponding value from an array in PHP
if (array_key_exists($key_to_check, $things)) {
return $things[$key_to_check];
}
I know this question is very old but for those who will come here It might be useful to know that in php7 you can use Null Coalesce Operator
if ($value = $things[ $key_to_check ] ?? null) {
//Your code here
}
if(isset($things[$key_to_check])){
echo $things[$key_to_check];
}