On Wed, Oct 20, 2010 at 4:16 PM, David Harkness <david.h@xxxxxxxxxxxxxxxxx> wrote: > On Wed, Oct 20, 2010 at 11:08 AM, Tommy Pham <tommyhp2@xxxxxxxxx> wrote: >> >> hmm.. ÂAbout 8-9 years ago I did a project where I used the reference >> in a foreach loop as the OP. Âunset not only remove the variable but >> also the value in the array. ÂI tried several methods at that time and >> ended up assigning null to get what I wanted without modifying the >> array. ÂI'll have to dig up that project later to see. > > To be thorough, I ran the same test as above using unset(), and it correctly > clears the reference and leaves $x in tact. > > ÂÂÂ $x = 5; > ÂÂÂ $y = &$x; > ÂÂÂ unset($y); > ÂÂÂ var_dump($x); > ÂÂÂ --> 5 > ÂÂÂ var_dump($y); > ÂÂÂ --> NULL > > It's quite possible this behavior was changed along the way. I started using > PHP last year with 5.2. > > David > Hi David, IIRC, I think at that time, PHP5 was still fresh. I remember a lot of the open source projects were written with PHP4 compatibility. I don't remember if that particular project of mine was written for PHP4 or 5. Any case, changes are good to an extent :). I also did confirm prior to your previous email, right after Gary showed me that quote from the manual. I'll have to remember that from now on :). Thanks, Tommy -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php