A direct look at the PHP array_reverse() function principle and example analysis

coldplay.xixi
Release: 2023-04-09 10:32:01
forward
2324 people have browsed it

A direct look at the PHP array_reverse() function principle and example analysis

##array_reverse
##(PHP 4, PHP 5, PHP 7)

array_reverse

—Returns an array with the cells in reverse order

Description


##array_reverse(array$array[,bool$preserve_keys= FALSE] ) :array

array_reverse() accepts an array array as input and returns a new array with the cells in reverse order.

Parameters


array

Input array

preserve_keys

If set to TRUE, numeric keys will be retained. Non-numeric keys are not affected by this setting and will always be retained.

Return value


Returns the reversed array.

Example

##Example #1array_reverse() example

``
Copy after login
The above routine will output:

Array ( [0] => php [1] => 4 [2] => Array ( [0] => green [1] => red ) ) Array ( [0] => Array ( [0] => green [1] => red ) [1] => 4 [2] => php ) Array ( [2] => Array ( [0] => green [1] => red ) [1] => 4 [0] => php )
Copy after login

Related learning recommendations:

PHP programming from entry to proficiency

The above is the detailed content of A direct look at the PHP array_reverse() function principle and example analysis. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jb51.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!