📜  PHP | Ds\Sequence reverse()函数

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

PHP | Ds\Sequence reverse()函数

Ds\Sequence::reverse()函数是PHP中的一个内置函数,用于就地反转序列。

句法:

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

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

返回值:该函数不返回任何值。

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

方案一:

reverse();
  
print_r($seq);
  
?>
输出:
Ds\Vector Object
(
    [0] => 1
    [1] => 2
    [2] => 3
    [3] => 4
    [4] => 5
)
Sequence after reversing
Ds\Vector Object
(
    [0] => 5
    [1] => 4
    [2] => 3
    [3] => 2
    [4] => 1
)

方案二:

reverse();
  
print_r($seq);
  
?>
输出:
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.reverse。 PHP