Reverse array in php

http://php.net/manual/en/function.array-reverse.php:

$newArray = array_reverse($theArray, true);

The important part is the true parameter, which preserves the keys.

Not convinced? You can see it in action on this codepad exampole.


foreach($array as $arr){

  array_unshift($array, $arr); 
  array_pop($array);

}