Checking if a Key Exists in an Array in PHP


Determine if a specific key is present in an array with array_key_exists().

Source Code

$array = ["name" => "John", "age" => 25];
if (array_key_exists("name", $array)) {
    echo "Key 'name' exists in the array.";
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments