|
Posted by Rami Elomaa on 05/21/07 16:00
gosha bine kirjoitti:
> On 20.05.2007 05:09 Jon Slaughter wrote:
>
>>
>> Well, your right. I assume that when it says copy it means a deep
>> copy. If so then essentially its working on a different variable...
>
> From my understanding, foreach doesn't make a copy of *entire array*,
> it just copies *current value* into the loop variable (unless you
> provided it by reference).
Here's a way to test it:
<?php
$a = range(0,4);
foreach($a as $k => $v){
if(isset($a)) unset($a);
echo "$k => $v<br>";
}
print_r($a);
?>
To me it would seem the entire array is copied, since it prints all the
values even after the array is unset, I got the output:
0 => 0
1 => 1
2 => 2
3 => 3
4 => 4
--
Rami.Elomaa@gmail.com
"Wikipedia on vähän niinq internetin raamattu, kukaan ei pohjimmiltaan
usko siihen ja kukaan ei tiedä mikä pitää paikkansa." -- z00ze
[Back to original message]
|