|
Posted by Schraalhans Keukenmeester on 05/20/07 15:22
At Sun, 20 May 2007 10:23:31 -0400, Jerry Stuckle let his monkeys type:
>>>>
>>>> I'd think setting elements to NULL directly in the array isn't any
>>>> better,
>>>> you're still relying on the same 'feature'.
>>>>
>>>> Sh
>>> Yes, foreach() works on a copy. But while the manual indicates changes to
>>> the copy don't affect the original - they say nothing about when changes
>>> to the original will affect the copy.
>>>
>>
>> since its a copy the original should effect in any way the copy?
>>
>> I could only see this if the copy is not a deep copy.... but in php all
>> copies are deep?
>>
>>
>
> There is nothing indicating when the copy is updated from the original.
> It might be only at the beginning, everything through the loop or
> anything else.
>
> It's not documented - so you can't depend on the operation.
In fact, there may be a hint the array behaviour isn't as straightforward
as it seems in this case. Good point Jerry. As in this example:
http://www.thescripts.com/forum/thread631554.html where it appears at
least the array pointer (which seemed unaffected in my earlier test)
doesn't behave completely as one would expect if a foreach operated on a
totally isolated array copy.
Sh.
Navigation:
[Reply to this message]
|