Blog Archives

PHP isset() and multi-dimentional array

** The issue discussed in this post has been fixed since PHP5.4.0, so the below discussion and solution are for PHP 5.3.x or lower. Thanks David for clarifying. A few weeks ago I covered how to check the existence of an array element in PHP. In the post I explained why isset() is dangerous to […]

PHP – isset() vs array_key_exists() : a better way to determine array element’s existence

The story In the CourseYou project, we’re asked to check if an element is set in an array. That is,  we’re asked to determine whether $Arr[‘MyElement’] exists. So we use the following code as a start. <?php if (isset($Arr[‘MyElement’])) { … do my stuff … } ?> This code works fine, but, it works fine […]