首页 > php函数 > php array_reverse 数组反序

php array_reverse 数组反序

array_reverse ( PHP 4中, PHP 5中) 

array_reverse -返回一个数组的内容次序颠倒

描述

阵列array_reverse (数组$阵列[ ,布尔$ preserve_keys =虚假] ) 

采取一种输入数组并返回一个新数组的命令的内容扭转。 

参数

阵列

输入数组。 

preserve_keys 

如果设置为TRUE键保存。 

返回值

返回扭转阵列。 

修改

版本说明

4.0.3参数的preserve_keys增加。 

实例

例如# 1 array_reverse()的例子

<?php
$input  = array("php", 4.0, array("green", "red"));
$result = array_reverse($input);
$result_keyed = array_reverse($input, true);
?>

 

This makes both $result and $result_keyed have the same elements, but note the difference between the keys. The printout of $result and $result_keyed will be:

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


本文地址:http://www.phprm.com/function/4a1c22852ec9a0085d6ab3c2a921a16e.html

转载随意,但请附上文章地址:-)

标签:none

发表留言