Home / PHP Tips Generated By ChatGPT / Checking If a Key Exists in an Array in PHP Use array_key_exists() to check if a specific key is present in an array. Source Code $fruits = ['apple' => 'red', 'banana' => 'yellow']; if (array_key_exists('apple', $fruits)) { echo "Apple exists in the array"; }