array_key_exists in php

Syntax of array_key_exists

bool array_key_exists(mixed key, array array)

Returns true if array contains a key with the value key. If no such key is available, returns false

Example of array_key_exists

<?php
$search_array = array('first' => 1, 'second' => 4);
if (array_key_exists('first', $search_array)) {
    echo "The 'first' element is in the array";
}
?>

Leave a Comment