Differences between isset and array_key_exists in PHP functions. The isset and array_key_exists methods are generally used to determine whether the index value of a PHP array exists. Isset ($ a [key]) array_key_exists (key, $ a) array_key_exists is used to determine whether the index value of a PHP array exists.
isset
And
array_key_exists
Two methods.
isset($a['key'])array_key_exists('key', $a)
array_key_exists
To tell you exactly whether an array has a keyisset
Only whether the return key value isnull
. That is to say, assume that the following array is given:
$a = array('key1' => '123', 'key2' => null);
Use these two methods to determine the existence of the key value:
isset($a['key1']); // truearray_key_exists('key1', $a); // trueisset($a['key2']); // falsearray_key_exists('key2', $a); // true
From the PHP engine itself, the underlying layer is implemented in C language,array_key_exists
Andisset
It should be fast. If the number of operations is more than timesisset
Performance should be more significant.
If the index value of the sort PHP array exists, the isset and array_key_exists methods are generally used. Isset ($ a ['key']) array_key_exists ('key', $ a) array_key_exists exact...