foreach() does neither modify nor unset the original array unless  
explicitly told to.
Maybe you're having issues with the array pointer?

http://jp2.php.net/foreach
> foreach has some side effects on the array pointer. Don't rely on  
> the array pointer during or after the foreach without resetting it.

http://jp2.php.net/manual/en/function.reset.php


$numbers = array(1, 2, 3, 4);

foreach ($numbers as $number) {
        $number = null;                 // does nothing to $numbers
}

print_r(current($numbers));     // prints nothing

reset($numbers);
print_r(current($numbers));     // prints '1'

print_r($numbers);                      // prints 'array([0] => 1, [1] => 2 
...)'

On 16 May 2008, at 22:26, Tony Thomas wrote:

>
> No. It's simply looping through and echoing the array, but once it
> does, the contents of the array are no longer available. As soon as I
> looped through using while(list($key, $value) = each($array) instead
> of a foreach loop, I was able to loop through it twice to create the
> second table. Please correct me if I'm wrong, but I presume it's
> because foreach() operates from a copy of the array, which is then
> unset after looping through the data. At least, that's what my results
> suggest. As soon as I switched methods as noted above, the data
> remained available to loop through again to create a second table from
> separate data in the array.
>
> On May 15, 4:20 pm, Dovdimus Prime <[EMAIL PROTECTED]> wrote:
>> Are you saying that this foreach loop is modifying the contents of  
>> the
>> array?
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to