David Harkness wrote: > Ah, so assigning a reference to a variable already holding a reference > changes that variable's reference only in the same way that unsetting a > reference doesn't unset the other variables referencing the same thing, yes? > > $a = 5; > $b = &$a; > print $a; >> 5 > unset($b); // does not affect $a > print $a; >> 5 > > // and according to Mike's previous message > $b = &$a; > $c = 10; > $b = &$c; // does not affect $a > print $a >> 5 > > That makes a lot of sense. If it didn't work this way there would be no easy > way to untangle references. In the case of > > foreach($array as $key => &$value) { ... } > > the first value in the array would continuously be overwritten by the next > value. > > 1. $value gets reference to first array value > 2. on each step through the loop, the first array value would be overwritten > by the next value in the loop since $value is forever tied to it by the > initial reference assignment. > > That would be a Bad Thing (tm). > > Thanks for the clarification, Mike. > > David > The big "aha" moment for was when realizing that when assigning a reference to a variable you only change its reference and not any other variable that may also have shared the same reference. Yuck that's a mouth full. This happened when Mike said, " NOTE: since we are assigning a new reference to a variable which is already a reference, ONLY this reference changes". Yes, i agree with you David (on both of your points). Thanks for the example using the unset. This further clarified/solidified my understanding. Now, with this new understanding, I also wish to comment that if i assign (without reference) $this, i don't have to be too worried about bloating the memory, b/c i'm only assigning/copying the identifer or *handle* and not the actual object itself. In case, someone reads this in the archive the link is: http://php.net/manual/en/language.oop5.references.php Mike, thank you a ton. Regards. ` -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php