Ds\Deque::clear()function是PHP中的内置函数, 用于通过从Deque中删除所有元素来清除Deque。
语法如下:
public Ds\Deque::clear( void ) : void
参数:该函数不接受任何参数。
返回值:此函数不返回任何值。
下面的程序说明了Ds\Deque::clear()PHP中的功能:
程序1:
<?php
// Declare deque of default size
$deck = new \Ds\Deque([1, 2, 3, 4, 5, 6]);
echo ( "Elements in the deck:\n" );
// Display the Deque elements
print_r( $deck );
// Use clear() function to clear the deque
$deck ->clear();
// Display the deque
print_r( $deck );
?>
输出如下:
Elements in the deck:
Ds\Deque Object
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
Ds\Deque Object
(
)
程式2:
<?php
// Declare deque of default size
$deck = new \Ds\Deque([ "geeks" , "for" , "geeks" ]);
echo ( "Elements in the Deque\n" );
// Display the Deque elements
print_r( $deck );
// Use clear() function to clear the deque
$deck ->clear();
echo ( "Alter clearing the elements\n" );
// Display the deque
print_r( $deck );
?>
输出如下:
Elements in the Deque
Ds\Deque Object
(
[0] => geeks
[1] => for
[2] => geeks
)
Alter clearing the elements
Ds\Deque Object
(
)
参考: http://php.net/manual/en/ds-deque.clear.php
更多PHP开发相关内容请参考:lsbin - IT开发技术:https://www.lsbin.com/
查看更多PHP相关内容:
- PHP MySQL:https://www.lsbin.com/3083.html
- PHP关联数组:https://www.lsbin.com/863.html
- PHP显示错误:https://www.lsbin.com/2615.html