Array_key_exists() function check if a key in array is defined or not, this does not matter if that key in array have value null or ‘’ empty, cause this is not checking if that key is set or not this is checking only if that key is created or not.
Suppose we have an array
[php]$products = array(‘first’ => null, ‘second’ => ‘Towels’, ‘third’ => ‘soaps’)
if(array_key_exists(‘first’, $products)) {
echo ‘First product is defined.’;
}
array_key_exists(‘first’, products); //will return true value.
//To check if this key have something or not we will use isset function like this
isset($products[‘first’]);
[/php]
This is the way how we can handle this situation to check if key is existing in our array or not.