[nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array)
Dan Cech
dcech at phpwerx.net
Mon Oct 25 12:25:57 EDT 2010
On 10/25/2010 12:22 PM, David Mintz wrote:
> Anybody know of any reason not to save a little typing with
>
> empty($array['foo'])
They're different comparisons, array_key_exists will return true if
there is an element with that key *even if it is null or some other
empty() value* (and the logic is reversed, you need !empty()),
isset($array['foo']) is closer but will return false if the value is null.
http://us3.php.net/manual/en/types.comparisons.php
Dan
More information about the talk
mailing list