I have an array:
array( 0 => \'contact\', 1 => \'home\', 2 => \'projects\' );
and I need to swap the \'contact\' with
Solution:
$a = array( 0 => 'contact', 1 => 'home', 2 => 'projects' );
list($a[0], $a[1]) = [$a[1], $a[0]];
I have made function for it
function swap(&$a, &$b){ list($a, $b) = [$b, $a]; }
Usage:
swap($a[0], $a[1]);