PHP Version
4+
$array = [1, 2, 3, 4, 5];

// Reverses the order of elements in the array.
print_r(array_reverse($array));
/* Output:
    Array (
        [0] => 5
        [1] => 4
        [2] => 3
        [3] => 2
        [4] => 1
    )
*/

// The original array is not modified.
print_r($array); 
/* Output:
    Array (
        [0] => 1
        [1] => 2
        [2] => 3
        [3] => 4
        [4] => 5
    )
*/
$associative_array = [
	'name' => 'John Doe',
	'age' => 30,
	'city' => 'New York'
];

// Reverses the order of elements in the array.
// The association between string keys and values is preserved.
print_r(array_reverse($associative_array));
/* Output:
    Array (
        [city] => New York
        [age] => 30
        [name] => John Doe
    )
*/

// The original array is not modified.
print_r($associative_array); 
/* Output:
    Array (
        [name] => John Doe
        [age] => 30
        [city] => New York

    )
*/
array_reverse(array $array, bool $preserve_keys = false): array
$original_array = ['apple', 'banana', 'cherry', 'date'];

// preserve_keys is not specified (default is false)
$reversed_array_default = array_reverse($original_array);
print_r($reversed_array_default);
/* Output:
	Array (
		[0] => date
		[1] => cherry
		[2] => banana
		[3] => apple
	)
*/

// preserve_keys is set to true
$reversed_array_preserved = array_reverse($original_array, true);
print_r($reversed_array_preserved);
/* Output:
	Array (
		[3] => date
		[2] => cherry
		[1] => banana
		[0] => apple
	)
*/
$original_array = ['apple', 'banana', 'cherry', 'date'];

// Output the array with reversed order
print_r(array_reverse($original_array));
/* Output:
	Array (
		[0] => date
		[1] => cherry
		[2] => banana
		[3] => apple
	)
*/
$associative_array = [
	'name' => 'John Doe',
	'age' => 30,
	'city' => 'New York'
];

// Output the reversed associative array
print_r(array_reverse($associative_array));
/* Output:
	Array (
		[city] => New York
		[age] => 30
		[name] => John Doe
	)
*/