PHP-функция: array_reverseСписок php-функций

javascript:

function array_reverse( array, preserve_keys ) {
	// Return an array with elements in reverse order
	// 
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
	// +   improved by: Karol Kowalski

	var arr_len=array.length, newkey=0, tmp_ar = {}

	for(var key in array){
		newkey=arr_len-key-1;
		tmp_ar[(!!preserve_keys)?newkey:key]=array[newkey];
	}

	return tmp_ar;
}

//Примеры:

   array_reverse( [ 'php', '4.0', ['green', 'red'] ], true );
// { 2: ['green', 'red'], 1: 4, 0: 'php'}