PHP.nl

array_key_exists

array_key_exists

Checks if the given key or index exists in the array

bool **array_key_exists**  $key array $array
returns true if the

given is set in the array. can be any value possible for an array index. array_key_exists``key``key

keyValue to check.

arrayAn array with keys to check.

return.success

Opmerking: > will search for the keys in the first dimension only. Nested keys in multidimensional arrays will not be found. array_key_exists

Voorbeeld: example

<?php
$searchArray = ['first' => 1, 'second' => 4];
var_dump(array_key_exists('first', $searchArray));
?>
bool(true)

**Voorbeeld: vs **

 does not return true for array keys
that correspond to a null value, while
 does.

isset``array_key_exists

<?php
$searchArray = ['first' => null, 'second' => 4];

var_dump(isset($searchArray['first']));
var_dump(array_key_exists('first', $searchArray));
?>
bool(false)
bool(true)

isset``array_keys``in_array``property_exists