Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

array_key_exists

Description

The array_key_exists of Array for PHP checks if the given key or index exists in the array.

Syntax

array_key_exists ( mixed $key , array $array ) : bool

Parameters

key

Value to check.

array

An array with keys to check.

Return

Returns TRUE on success or FALSE on failure.

Examples

1

<?

$key = 1;
$array = array(0, 1);

$return = array_key_exists($key, $array);

var_export($return);

?>
true

2

<?

$key = "b";
$array = array("a" => 0, "b" => 1);

$return = array_key_exists($key, $array);

var_export($return);

?>
true

3

<?

$key = 1;
$array = array(0, null);

$return = array_key_exists($key, $array);

var_export($return);

?>
true

4

<?

$key = "b";
$array = array("a" => 0, "b" => null);

$return = array_key_exists($key, $array);

var_export($return);

?>
true
HomeMenu