php8.5
Home/ Manual/ ds / stack/ Ds\Stack::clear

Ds\Stack::clear

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Removes all values

Description

Ds\Stack::clear(): void

Removes all values from the stack.

Parameters Parameters

Return Values

Void

Examples

Ds\Stack::clear() example

php
<?php
$stack = new \Ds\Stack([1, 2, 3]);
print_r($stack);

$stack->clear();
print_r($stack);
?>

The above example will output something similar to:

output
Ds\Stack Object
(
    [0] => 3
    [1] => 2
    [2] => 1
)
Ds\Stack Object
(
)

Source: reference/ds/ds/stack/clear.xml · from the official PHP manual (php/doc-en)