Skip to content

Instantly share code, notes, and snippets.

@adamneilson
Created February 25, 2013 14:04
Show Gist options
  • Save adamneilson/5029974 to your computer and use it in GitHub Desktop.
Save adamneilson/5029974 to your computer and use it in GitHub Desktop.
Swap variables values without the use of a third trivial interview question.
// set the initial values
$a = 100;
$b = 200;
// swap them!
$a = $a + $b; // $a == 300
$b = $a - $b; // $b == 100
$a = $a - $b; // $a == 200
// done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment