Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Created June 17, 2013 12:07
Show Gist options
  • Save pmgupte/5796407 to your computer and use it in GitHub Desktop.
Save pmgupte/5796407 to your computer and use it in GitHub Desktop.
Many of the times we face a typical question in interviews: “swap two variables without using third variable”. well, when I ask the same question while interviewing any candidate for PHP, I get the same typical answer of adding and subtracting the two variables. But when I ask them to do it with only one executable statement, they simply can’t. …
<?php
$a=10; $b=20;
list($b, $a) = array($a,$b);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment