Geoff Caplan 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?

IMHO what you have described is a bug in PHP, and if I were you, I'd report it as
such.  If it's not a bug it at least has a very high WTF factor.  Having to use the
cumbersome:

is_array($foo['one']['two']) && array_key_exists('three', $foo['one']['two'])

instead of:

isset($foo['one']['two']['three'])

seems kinda silly to me.  I doubt that this is the intended behavior.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to