Click to See Complete Forum and Search --> : Exchanging Variables without Temporary Var


pcthug
03-16-2007, 03:35 AM
Hi, So I'm just wondering how you guys exchange variables? I usually use Temporary Variables and then if they were in the global scope unset them, but I need something more maintainable. Currently I'm using the following though Its quite taxing on server resources
$a = 'World';
$b = 'Hello';

$a ^= $b ^= $a ^= $b;

echo "$a $b"; // Hello World
So does anyone have a better method?

BoarsHell
03-16-2007, 07:46 AM
pcthug you may find this quick article helpful with understanding how garbage collection works in php... http://www.hudzilla.org/php/18_1_11.php