On Wed, Nov 23, 2011 at 4:31 PM, Daniel Convissor < dani...@analysisandsolutions.com> wrote:
> Hi Again Folks: > > On Wed, Nov 23, 2011 at 09:14:09AM -0500, Daniel Convissor wrote: > > $a = 'foo'; > > echo $a['blah'] . "\n"; > > > > But that second one echos out "f". This is a huge WTF. > > Two things for the record on this front. First, i've been actively > using PHP for, what, ten years or so, and have never run into this > behavior before. Second, this behavior turns the following one liner: > > if (isset($arr['package']['attribs']['version'])) { > > Into this: > > if (is_array($arr) > && array_key_exists('package', $arr) > && is_array($arr['package']) > && array_key_exists('attribs', $arr['package']) > && is_array($arr['package']['attribs']) > && array_key_exists('version', $arr['package']['attribs']) > && !empty($arr['package']['attribs']['version'])) > { > it is only necessary if you can't guarantee your data structure (so that you can get a string where you expect an array) -- Ferenc Kovács @Tyr43l - http://tyrael.hu