DEV Community

Discussion on: How can you swap two variables without using a third?

Collapse
 
jjjjcccjjf profile image
endan • Edited

$a = 7;
$b = 9;

list($b, $a) = [$a, $b];

echo "a is " . $a; # 9
echo "b is " . $b; # 7

/* scratches head */