Re: Re: Possible foreach bug; seeking advice to isolate the problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 20, 2010 at 11:08 AM, Tommy Pham <tommyhp2@xxxxxxxxx> wrote:

> hmm..  About 8-9 years ago I did a project where I used the reference
> in a foreach loop as the OP.  unset not only remove the variable but
> also the value in the array.  I tried several methods at that time and
> ended up assigning null to get what I wanted without modifying the
> array.  I'll have to dig up that project later to see.
>

To be thorough, I ran the same test as above using unset(), and it correctly
clears the reference and leaves $x in tact.

    $x = 5;
    $y = &$x;
    unset($y);
    var_dump($x);
    --> 5
    var_dump($y);
    --> NULL

It's quite possible this behavior was changed along the way. I started using
PHP last year with 5.2.

David

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux