Using array_key_exists() to Check if an Array Key Exists in PHP


Determine if a specified key is present in an array.

Source Code

$array = array("first" => 1, "second" => 4);
if (array_key_exists("first", $array)) {
    echo "The 'first' element is in the array";
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments