Ds \ Sequence::reverse()函数是PHP中的一个内置函数,用于就地反转序列。
用法:
void abstract public Ds\Sequence::reverse ( void )
参数:该函数不接受任何参数。
返回值:该函数不返回任何值。
以下示例程序旨在说明PHP中的Ds \ Sequence::reverse()函数:
程序1:
<?php
// Create new Vector
$seq = new \Ds\Vector([1, 2, 3, 4, 5]);
// Display the elements
print_r($seq);
echo("Sequence after reversing\n");
// Use reverse() function to reverse
// the element and display it
$seq->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 )
程序2:
<?php
// Create new Vector
$seq = new \Ds\Vector(["Geeks", "for", "Geeks",
"Computer", "Science", "Portal"]);
// Display the elements
print_r($seq);
echo("Sequence after reversing\n");
// Use reverse() function to reverse
// the element and display it
$seq->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
相关用法
- PHP Ds\Map reverse()用法及代码示例
- p5.js reverse()用法及代码示例
- PHP Ds\Set reverse()用法及代码示例
- PHP Ds\Deque reverse()用法及代码示例
- PHP Ds\Vector reverse()用法及代码示例
- Node.js dnsPromises.reverse()用法及代码示例
- PHP max( )用法及代码示例
注:本文由纯净天空筛选整理自R_Raj大神的英文原创作品 PHP | Ds\Sequence reverse() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。