Re: [PHP] Strange foreach reference issue

2012-01-09 Thread Tim Behrendsen
On 1/9/2012 10:35 AM, David Harkness wrote: On Sat, Jan 7, 2012 at 5:01 PM, Tim Behrendsen > wrote: The first loop is leaving a reference to the final element. But then the second foreach is doing a straight assignment to the $row variable, but $row is a r

Re: [PHP] Strange foreach reference issue

2012-01-09 Thread David Harkness
On Sat, Jan 7, 2012 at 5:01 PM, Tim Behrendsen wrote: > The first loop is leaving a reference to the final element. But then the > second foreach is doing a straight assignment to the $row variable, but > $row is a reference to the final element. So the foreach is assigning its > iterated value t

Re: [PHP] Strange foreach reference issue

2012-01-08 Thread Adi Mutu
t: Re: [PHP] Strange foreach reference issue On 1/7/2012 4:44 PM, Stephen wrote: > On 12-01-07 07:30 PM, Tim Behrendsen wrote: >> >> When you use an ampersand on the variable, that creates a reference to the >> array elements, allowing you to potentially change the array elem

Re: [PHP] Strange foreach reference issue

2012-01-07 Thread Tim Behrendsen
On 1/7/2012 4:44 PM, Stephen wrote: On 12-01-07 07:30 PM, Tim Behrendsen wrote: When you use an ampersand on the variable, that creates a reference to the array elements, allowing you to potentially change the array elements themselves (which I'm not doing here). http://www.php.net/manual/e

Re: [PHP] Strange foreach reference issue

2012-01-07 Thread Stephen
On 12-01-07 07:30 PM, Tim Behrendsen wrote: When you use an ampersand on the variable, that creates a reference to the array elements, allowing you to potentially change the array elements themselves (which I'm not doing here). http://www.php.net/manual/en/control-structures.foreach.php I d

Re: [PHP] Strange foreach reference issue

2012-01-07 Thread Tim Behrendsen
On 1/7/2012 4:18 PM, Matijn Woudt wrote: On Sun, Jan 8, 2012 at 12:29 AM, Tim Behrendsen wrote: Hello, This sure looks like a bug, but maybe there's some subtlety going on that I don't understand, so I would appreciate some insight. After much debugging, I tracked down a bug in my code to this

Re: [PHP] Strange foreach reference issue

2012-01-07 Thread Matijn Woudt
On Sun, Jan 8, 2012 at 12:29 AM, Tim Behrendsen wrote: > Hello, > > This sure looks like a bug, but maybe there's some subtlety going on that I > don't understand, so I would appreciate some insight. After much debugging, > I tracked down a bug in my code to this test program. My PHP version is >

Re: [PHP] Strange foreach reference issue

2012-01-07 Thread Stephen
I cut and pasted your code and got the same result. I flipped the two foreach blocks and got the expected results. I deleted the first block and copied the second, then updated the string. I got this. I can't explain. 'Title #1', ), array( 'Title' => 'Title #2',