note 39444 deleted from language.operators.assignment by bjori

From: Date: Sat, 21 Apr 2007 08:11:58 +0000
Subject: note 39444 deleted from language.operators.assignment by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-125746@lists.php.net to get a copy of this message
Note Submitter: jeronimo at DELETE_THIS dot transartmedia dot com ---- If you want to swap values between variables without using an intermediary, try using the list() and array() language constructs. For instance: <? // Initial values. $biggest = 1; $smallest = 10; // Instead of using a temporary variable... $temp = $biggest; $biggest = $smallest; $smallest = $temp; // ...Just swap the values. list($biggest, $smallest) = array($smallest, $biggest); ?> This works with any number of variables; you're not limited to just swapping two. Cheers, Jeronimo

« previous php.notes (#125746) next »