<?php
// Define an associative array
$userProfile = [
'name' => 'John Doe',
'email' => '[email protected]',
'age' => 30,
'country' => 'USA'
];
// Key to check
$keyToCheck = 'email';
// Use array_key_exists to check if the key exists in the array
if (array_key_exists($keyToCheck, $userProfile)) {
echo "The key '$keyToCheck' exists in the array with value: " . $userProfile[$keyToCheck];
} else {
echo "The key '$keyToCheck' does not exist in the array.";
}
?>