note 39445 added to function.list

From: Date: Thu, 29 Jan 2004 00:28:57 +0000
Subject: note 39445 added to function.list
Groups: php.notes 
Request: Send a blank email to php-notes+get-64341@lists.php.net to get a copy of this message
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 two. Cheers, Jeronimo ---- Manual Page -- http://www.php.net/manual/en/function.list.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39445 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39445&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39445&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#64341) next »