On Wed, Mar 13, 2013 at 4:44 PM, Angela Barone
<ang...@italian-getaways.com>wrote:

> I ran across if(array_key_exists) and it seems to work.  How does that
> differ from if(isset($states[$state]))?


Hi Angela,

isset() will return false for an array key 'foo' mapped to a null value
whereas array_key_exists() will return true. The latter asks "Is this key
in the array?" whereas isset() adds "and is its value not null?" While
isset() is every-so-slightly faster, this should not be a concern. Use
whichever makes sense for the context here. Since you don't stick null
values into the array, I prefer the isset() form because the syntax reads
better to me.

Peace,
David

Reply via email to