Re: Re[2]: [PHP] Odd behaviour of non-existent keys?

From: Date: Wed, 25 Aug 2004 13:16:26 +0000
Subject: Re: Re[2]: [PHP] Odd behaviour of non-existent keys?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-194676@lists.php.net to get a copy of this message
On Wed, 25 Aug 2004 14:04:51 +0100, Geoff Caplan <geoff@variosoft.com> wrote: > I think you are probably right - but this behaviour causes problems. > For example: > > $foo['one']['two'] = "test-string" ; > > // Evaluates to TRUE (not what's wanted!) > isset( $foo['one']['two']['three'] ) ; > > I need a reliable way to test for the non-existence of a > multi-dimensional key. Any ideas? I guess I could convert the keys > into a string via a loop and compare that, but there must be a more > elegant way, surely? > > ------------------ > Geoff Caplan > How about array_key_exists? array_key_exists('three', $foo['one']['two']); http://jp2.php.net/manual/en/function.array-key-exists.php ---- ramil http://ramil.sagum.net

« previous php.general (#194676) next »