To Swap $a and $b:
$a = 'Alice'; $b = 'Bob'; list($a, $b) = array($b, $a);
PHP’s list() language construct lets you assign values from an array to individual variables. Its counterpart on the right side of the expression, array(), lets you construct arrays from individual values. Assigning the array that array() returns to the variables in the list() lets you juggle the order of those values, This works with more than tow values.