PHP | Ds\Vector reverse()函数
Ds\Vector::reverse()函数是PHP中的一个内置函数,用于就地反转向量元素。
句法:
void public Ds\Vector::reverse( void )
参数:此函数不接受任何参数。
返回值:此函数不返回任何值。
下面的程序说明了PHP中的Ds\Vector::reverse()函数:
方案一:
reverse();
print_r($arr);
?>
输出:
Ds\Vector Object
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
)
Vector after reversing
Ds\Vector Object
(
[0] => 5
[1] => 4
[2] => 3
[3] => 2
[4] => 1
)
方案二:
reverse();
print_r($arr);
?>
输出:
Ds\Vector Object
(
[0] => Geeks
[1] => GFG
[2] => Computer
[3] => Science
[4] => Portal
)
Vector after reversing
Ds\Vector Object
(
[0] => Portal
[1] => Science
[2] => Computer
[3] => GFG
[4] => Geeks
)
参考: https://www. PHP.net/manual/en/ds-vector.reverse。 PHP