PHP array reverse sorting is the "array_reverse()" function. The array_reverse() function can flip the order of array elements and return the array in the opposite order of elements. The syntax is "array_reverse($array,$preserve)"; the second parameter "$preserve" of this function can be omitted and is used to specify whether to preserve it. The key name of the original array. If the value is set to true, the key name remains unchanged, otherwise the key name will be lost (the key name starts again from 0 and increases by 1).
The operating environment of this tutorial: Windows 7 system, PHP version 8.1, DELL G3 computer
php array reverse sorting is "array_reverse ()"function.
array_reverse() function returns an array in reverse element order.
array_reverse($array,$preserve)
Parameters | Description |
---|---|
array | Required . Specifies an array. |
preserve | Optional. Specifies whether to retain the original array key names. This parameter is newly added in PHP 4.0.3. Possible values:
|
# #Description
$preserve is specified as true, the key name of the element remains unchanged, otherwise the key name will be lost (the returned array will use the index In the form of an array, the index of the array starts from 0 and increases by 1.).
<?php header('content-type:text/html;charset=utf-8'); $a=array("Volvo","XC90","BMW","Toyota"); $reverse=array_reverse($a); $preserve=array_reverse($a,true); var_dump($a); var_dump($reverse); var_dump($preserve); ?>
PHP Video Tutorial"
The above is the detailed content of Which function is used to reverse sort php arrays?. For more information, please follow other related articles on the PHP Chinese website!