note 105551 deleted from language.references.arent by danbrown

From: Date: Fri, 26 Aug 2011 14:58:32 +0000
Subject: note 105551 deleted from language.references.arent by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182758@lists.php.net to get a copy of this message
Note Submitter: pvbemmel at xs4all dot nl ---- In C++/Java I was unable to make a function that swaps two variables. If the two variables were pointers, then I was able to make a function that swaps the values pointed to by the pointers, but not the pointers themselves. In php it looks like I can do swap(int,int) : The page below will show $a: a $b: b $a: b $b: a <?php function swap(&$first, &$second) { $tmp = $first; $first = $second; $second = $tmp; } $a = "a"; $b = "b"; echo "\$a: $a <br/>"; echo "\$b: $b <br/>"; swap($a, $b); echo "\$a: $a <br/>"; echo "\$b: $b <br/>"; ?>

« previous php.notes (#182758) next »