In PHP arrays, the array_key_exists() function is used when the user wants to check if a specific key is present inside an array. If the function returns with a TRUE value, it is present.

Here’s its syntax: array_key_exists(array_key, array_name)

Also, here is an example of how it works

BY Best Interview Question ON 07 Apr 2020

Example

$array1 = array("Orange" => 100, "Apple" => 200, "Grapes" => 300, "Cherry" => 400);
if (array_key_exists("Grapes",$array1))
{
echo "Key exists";
}
else
{
echo "Key does not exist";
}

Output:

key exists