Re: 1 last error to fix before the application is done!
| From: | Colin Guthrie | Date: | Tue, 14 Oct 2008 12:52:31 +0000 |
| Subject: | Re: 1 last error to fix before the application is done! | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-281864@lists.php.net to get a copy of this message | ||
Yeti wrote:
You might also want to try array_key_exists if (array_key_exists('loggedin', $_SESSION['userInfo'])) { // do something with $_SESSION['userInfo']['loggedin'] }You'd first need to check that the key 'userInfo' existed in the $_SESSION array too. Personally, I very rarely see the point in using array_key_exists... It's a function call and has overhead where as isset() and empty() are language constructs and (I would hope) are much more efficient (although I've not done any benchmarks). There are cases where you may want to use array_key_exists where isset() and empty() would fail, e.g. $arr['foo'] = null; isset($arr['foo']) == false !empty($arr['foo']) == false array_key_exists('foo', $arr) == true Col -- Colin Guthrie gmane(at)colin.guthr.ie http://colin.guthr.ie/ Day Job: Tribalogic Limited [http://www.tribalogic.net/] Open Source: Mandriva Linux Contributor [http://www.mandriva.com/] PulseAudio Hacker [http://www.pulseaudio.org/] Trac Hacker [http://trac.edgewall.org/]