5
In PHP we often have more than one way to do the same operation. A basic example is in verifying the existence of a given index in a array
: we can use array_keys_exists
.
Example:
$arr = ['a' => 1, 'b' => 2];
var_dump(isset($arr['a'])); // bool(true)
var_dump(array_key_exists($arr, 'a')); //bool(true)
Considering that the results are the same, I would like to know:
Is there any difference between
isset
andarray_keys_ exists
when verifying the existence of the index?There is a difference in performance?
When you should wear one or the other?
This helps with something http://answall.com/a/63550/3635 ?
– Guilherme Nascimento
In the manual says: isset() does not return TRUE for key values that match a NULL value, while array_key_exists() does this.
– Papa Charlie