← All built-ins / array_key_exists()

array_key_exists()

array_key_exists(...$args): bool

Parameters

NameTypeDescription
$keystring|intkey to test
$aarrayarray to test

Return value

true when the key exists — also when its value is null (unlike isset).

Example

$m = ["k" => null];
var_dump(array_key_exists("k", $m));
var_dump(isset($m["k"]));
bool(true)
bool(false)

See also

isset()in_array()