Re: 5.4 regression: non-existent sub-sub keys now have values
| From: | Ferenc Kovacs | Date: | Wed, 23 Nov 2011 09:58:29 +0000 |
| Subject: | Re: 5.4 regression: non-existent sub-sub keys now have values | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-56495@lists.php.net to get a copy of this message | ||
On Wed, Nov 23, 2011 at 10:51 AM, Lester Caine <lester@lsces.co.uk> wrote:
> Ferenc Kovacs wrote:
>
>> some clarification:
>> in the test script, Daniel declared $arr as:
>> $arr = array('exists' => 'foo');
>> so when he tests
>> $arr['exists']['non_existent']
>> PHP will see that $arr['exists'] is a string, and it will convert the
>> 'non_existent' index to int(0) and that will return the same
>> as $arr['exists'][0]: 'f'
>> If he would have defined $arr['exists'] as an array, then the code would
>> work as
>> he expected, empty would returned true for
>> $arr['exists']['non_existent']
>>
>
> The bit I am missing here is the statement that $arr = array ... has NOT
> created an array with an element ['exists']
yes it did, but ['exists'] wasn't defined as an array, but as a string.
> ... I suspect that this is perhaps where the code *I* am looking at is
> breaking down ... how SHOULD you define the array so that it is an array?
> So that $family = array ( 'fam1' => 'JONES' ); is the base for the JONES
> family rather than simply a string. All of this USED to be simple, but it
> seems to be getting so cryptic that this is what is causing the trouble :(
I think you just need a coffee.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu