📜  PHP | Ds\Sequence reversed()函数

📅  最后修改于: 2022-05-13 01:56:27.239000             🧑  作者: Mango

PHP | Ds\Sequence reversed()函数

Ds\Sequence::reversed()函数是PHP中的一个内置函数,用于返回序列元素的反向副本。

句法:

Ds\Sequence abstract public Ds\Sequence::reversed ( void )

参数:此函数不接受任何参数。

返回值:此函数返回序列元素的反向副本。

下面的程序说明了PHP中的Ds\Sequence::reversed()函数:

方案一:

reversed()); 
  
?> 
输出:
Ds\Vector Object
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)
After reversing the sequence elements
Ds\Vector Object
(
    [0] => 5
    [1] => 4
    [2] => 3
    [3] => 2
    [4] => 1
)

方案二:

reversed());
  
?>
输出:
Ds\Vector Object
(
    [0] => Geeks
    [1] => for
    [2] => Geeks
    [3] => Computer
    [4] => Science
    [5] => Portal
)
Sequence after reversing
Ds\Vector Object
(
    [0] => Portal
    [1] => Science
    [2] => Computer
    [3] => Geeks
    [4] => for
    [5] => Geeks
)

参考: https://www. PHP.net/manual/en/ds-sequence.reversed。 PHP