php8.5
Home/ Manual/ ds / collection/ Ds\Collection::clear

Ds\Collection::clear

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Removes all values

Description

Ds\Collection::clear(): void

Removes all values from the collection.

Parameters Parameters

Return Values

Void

Examples

Ds\Collection::clear() example

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

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

The above example will output something similar to:

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

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