I've turned on all error reporting to clean up some undefined indexes, just to make the app I'm making more neat. I've noticed a curious behavior:
Let's say I have the following array: $a = array('test' => false, 'foo' => 'bar')
If I do if ($a['nothere'])
, I properly get a notice of Undefined index: nothere
.
However, if I do if ($a['test']['nothere'])
, I don't get a notice. At all. Despite nothere
definitely not being an index in $a['test']
.
Now, if I do $a['test'] = array('baz' => 'poof')
, then running if ($a['test']['nothere'])
does throw a notice.
Does undefined index checking not check for indexes in an empty array? This is on PHP 5.2.8.