Your code will work, but it exposes a misunderstanding that you have. There is no need to use an array, @temp, to store your array element, $blocks[$blockcount][4], because your array element is a scalar variable. In fact, all array elements are scalars. In your case, that scalar just happens to be a reference to another array.
Your code works because it is simply using the first element of @temp as a temporary variable. This is what you meant to do:
And that will be sufficient. You can also use the shorthand that dws suggested to swap values without a temporary variable.$temp = $blocks[$blockcount][4]; $blocks[$blockcount][4] = $blocks[$blockcount][5]; $blocks[$blockcount][5] = $temp;
-sauoq "My two cents aren't worth a dime.";
In reply to Re: Swapping two values
by sauoq
in thread Swapping two values
by stu96art
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |