Array_key_exists () of the php array function sequence-query whether the array key name exists. Array_key_exists () definition and usage the array_key_exists () function determines whether a specified key exists in an array. if the key exists, true is returned; otherwise, false is returned. Syntax ar
Array_key_exists () definition and usage
The array_key_exists () function checks whether a specified key exists in an array. if the key exists, true is returned; otherwise, false is returned.
Syntax
Array_key_exists (key, array)
Parameter description
Key is required. Specifies the key name.
Array is required. Specifies the input array.
Example 1
The code is as follows:
$ A = array ("a" => "Dog", "B" => "Cat ");
If (array_key_exists ("a", $ ))
{
Echo "Key exists! ";
}
Else
{
Echo "Key does not exist! ";
}
?>
Output:
Key exists!
Example 2
The code is as follows:
$ A = array ("a" => "Dog", "B" => "Cat ");
If (array_key_exists ("c", $ ))
{
Echo "Key exists! ";
}
Else
{
Echo "Key does not exist! ";
}
?>
Output:
Key does not exist!
Example 2
The code is as follows:
$ A = array ("Dog", Cat ");
If (array_key_exists (0, $ ))
{
Echo "Key exists! ";
}
Else
{
Echo "Key does not exist! ";
}
?>
Output:
Key exists!
The http://www.bkjia.com/PHPjc/324493.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324493.htmlTechArticlearray_key_exists () definition and usage array_key_exists () function determines whether a specified key exists in an array. if the key exists, true is returned; otherwise, false is returned. Syntax ar...