How to reverse the order of an array in php: You can use the array_reverse() function to reverse the array. Function syntax: [array_reverse(array,preserve)], the parameter preserve specifies whether to retain the key name of the original array.
array_reverse() function returns an array in reverse order.
(Recommended tutorial: php graphic tutorial)
Syntax:
array_reverse(array,preserve)
Parameters:
array Required. Specifies an array.
preserve Optional. Specifies whether to retain the original array key names.
(Video tutorial recommendation: Introduction to Programming)
Code implementation:
<?php $a=array("Volvo","XC90",array("BMW","Toyota")); $reverse=array_reverse($a); $preserve=array_reverse($a,true); print_r($a); print_r($reverse); print_r($preserve); ?>
The above is the detailed content of How to reverse array order in php. For more information, please follow other related articles on the PHP Chinese website!