php array_reverse() function
Translation results:
UK[rɪˈvɜ:s] US[rɪˈvɜ:rs]
vt.& vi. (to make) reverse; (to make) reverse; swap, exchange; [French] cancel, overturn
vi.Backward;[Bridge]Reverse
adj.Reverse; reversed; reversed; [raw] reversed
n.Inverted, reverse;[ machine] to reverse; to reverse; to fail
Third person singular: reverses Plural: reverses Present participle: reversing Past tense: reversed Past participle: reversed
php array_reverse() functionsyntax
Function: Return the array in reverse element order
Syntax: array_reverse(array,preserve)
Parameters:
Parameter | Description |
array | Required. Specifies an array. |
preserve | Optional. Specifies whether to retain the key names of the original array. |
Instructions: Reverse the order of elements in the original array, create a new array and return it. If the second parameter is specified as true, the element's key name remains unchanged, otherwise the key name is lost.
php array_reverse() functionexample
<?php $a = array("class" => "php中文网","name" => "西门","job" => "讲师"); print_r(array_reverse($a)); ?>
Run instance»
Click the "Run instance" button to view the online instance
Output:
Array ( [job] => 讲师 [name] => 西门 [class] => php中文网 )
<?php $a=array("a"=>"Volvo","b"=>"BMW","c"=>"Toyota"); print_r(array_reverse($a)); ?>
Run Instance»
Click the "Run Instance" button to view the online instance
Output:
Array ( [c] => Toyota [b] => BMW [a] => Volvo )