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 10:44 AM, David Harkness
<david.h@xxxxxxxxxxxxxxxxx> wrote:
> On Wed, Oct 20, 2010 at 5:00 AM, Tommy Pham <tommyhp2@xxxxxxxxx> wrote:
>>
>> Shouldn't that be $row = null since unset will remove the last value, not
>> just removing the variable also, from the array whereas the $row = null
>> will
>> tell the reference pointer that it doesn't point to a value.
>
> No, that would assign null to the last array element. References allow you
> to assign any value--including null--to the container they reference.
> Unsetting a reference breaks the reference without affecting whatever it
> references.
>
> ÂÂÂ $x = 5;
> ÂÂÂ $y = &$x;
> ÂÂÂ $y = null;
> ÂÂÂ print_r($x);
> ÂÂÂ var_dump($x);
>
> ÂÂÂ --> NULL
>
> David
>

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.

Thanks,
Tommy

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




[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