# arrow_back How do I make a clockwise permutation of an array?

Hi, could you please tell me where the last element of the array goes and why  element is the same as the zero element?

I just need to make a permutation from 1,2,3,4,5,6, 7---> 7,1,2,3,4,5,6

``\$mylist2 = array(1,2,3,4,5,6,7);\$mylist2=\$mylist2[(count(\$mylist2)-1)];\$my = \$mylist2;\$i=0;	while (\$i < count(\$mylist2)-1) {				\$mylist2[\$i+1] = \$my[\$i];		echo"\$mylist2[\$i], ";		\$i++;	}``
THANK YOU!

``\$mylist2 = array(1,2,3,4,5,6,7);\$count = count(\$mylist2);\$newArray = array();foreach ( \$mylist2 as \$key => \$value ) {	if ( (\$count-1) == \$key ) {		\$newArray = \$value;	} else {		\$newArray[\$key+1] = \$value;	}}ksort(\$newArray);var_dump(implode(", ", \$newArray));``
``function rotateArray(\$arr, \$shift) {  \$shift %= count(\$arr);  array_unshift(\$arr, ...array_splice(\$arr, -\$shift));  return \$arr;}\$arr = range(1, 7);echo implode(', ', rotateArray(\$arr,  1)); // 7, 1, 2, 3, 4, 5, 6echo implode(', ', rotateArray(\$arr, -3)); // 4, 5, 6, 7, 1, 2, 3echo implode(', ', rotateArray(\$arr, 69)); // 2, 3, 4, 5, 6, 7, 1``
``\$data  = [1,2,3,4,5,6,7];\$last = array_pop(\$data);array_unshift(\$data, \$last);echo implode(', ', \$data);P.s.: читайте доку php.net``