DEV Community

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

Collapse
 
svenluijten profile image
Sven Luijten
// Since PHP 7.1:
[$b, $a] = [$a, $b];

// Or before 7.1:
list($b, $a) = [$a, $b];