Javatpoint Logo
Javatpoint Logo

PHP key_exists() function

The PHP key_exists( ) function is used to check if the given key or index exists in the array. It is an alias of array_key_exists( ).This function was introduced in PHP 4.0.6.

Syntax

Parameter

Parameter Description Is compulsory
array Specifies the array to use. compulsory
key Specifies the key. compulsory

Returns

The function returns true if the key exists and false if the key does not exist.

Example 1

Output:

Key exists!

Example 2

Output:

Key exists!

Example 3

Output:

Key exists!

Example 4

Output:

Key exists!





Help Others, Please Share

facebook twitter pinterest