Php check if array element exists

[PHP 4 >= 4.0.7, PHP 5, PHP 7, PHP 8]

array_key_existsChecks if the given key or index exists in the array

Description

array_key_exists[string|int $key, array $array]: bool

Parameters

key

Value to check.

array

An array with keys to check.

Return Values

Returns true on success or false on failure.

Note:

array_key_exists[] will search for the keys in the first dimension only. Nested keys in multidimensional arrays will not be found.

Examples

Example #1 array_key_exists[] example

Chủ Đề