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

2010-10-25 Thread David Harkness
On Sat, Oct 23, 2010 at 6:48 PM, Jonathan Sachs <081...@jhsachs.com> wrote: > Now that I understand it, I can see the same thing would happen if I > wrote the equivalent code in C, and probably in Java. > Neither C nor Java have references as PHP does, and references in C++ cannot be changed to p

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

2010-10-23 Thread Jonathan Sachs
On Sat, 23 Oct 2010 16:56:52 +0200, peter.e.l...@gmail.com (Peter Lind) wrote: >More information (and a complete breakdown of your problem) is >available here: >http://schlueters.de/blog/archives/141-References-and-foreach.html Thank you! The situation is obscure and confusing, but that explanati

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

2010-10-23 Thread Peter Lind
On 23 October 2010 16:48, Jonathan Sachs <081...@jhsachs.com> wrote: > On Sat, 23 Oct 2010 08:34:27 +0200, peter.e.l...@gmail.com (Peter > Lind) wrote: > >>It is not a bug - somewhere before the foreach loop you've got, a >>variable is being referenced, and that's throwing things off. >>Otherwise,

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

2010-10-23 Thread Jonathan Sachs
On Sat, 23 Oct 2010 08:34:27 +0200, peter.e.l...@gmail.com (Peter Lind) wrote: >It is not a bug - somewhere before the foreach loop you've got, a >variable is being referenced, and that's throwing things off. >Otherwise, unsetting the variable would have no effect on the problem >you're seeing. C

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

2010-10-22 Thread Peter Lind
On 23 October 2010 07:50, Jonathan Sachs <081...@jhsachs.com> wrote: > Gary wrote: > >>Better. I can tell you how to solve it: >>    $a = array('a', 'b','c'); >>    foreach($a as &$row){ >>        //you don't have to do anything here >>    } >>    unset($row); // <<<< THIS IS KEY! >>    print_r

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

2010-10-20 Thread Tommy Pham
On Wed, Oct 20, 2010 at 4:16 PM, David Harkness wrote: > On Wed, Oct 20, 2010 at 11:08 AM, Tommy Pham 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

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

2010-10-20 Thread David Harkness
On Wed, Oct 20, 2010 at 11:08 AM, Tommy Pham 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

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

2010-10-20 Thread Tommy Pham
On Wed, Oct 20, 2010 at 10:44 AM, David Harkness wrote: > On Wed, Oct 20, 2010 at 5:00 AM, Tommy Pham 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 poi

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

2010-10-20 Thread David Harkness
On Wed, Oct 20, 2010 at 5:00 AM, Tommy Pham 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 n

RE: [PHP] Re: Possible foreach bug; seeking advice to isolate the problem

2010-10-20 Thread Tommy Pham
> -Original Message- > From: Gary [mailto:php-gene...@garydjones.name] > Sent: Tuesday, October 19, 2010 11:38 PM > To: php-general@lists.php.net > Subject: [PHP] Re: Possible foreach bug; seeking advice to isolate the > problem > > Jonathan Sachs wrote: > > I've got a script which origina