php8.5
Home/ Manual/ ds / map/ Ds\Map::clear

Ds\Map::clear

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Removes all values

Description

Ds\Map::clear(): void

Removes all values from the map.

Parameters Parameters

Return Values

Void

Examples

Ds\Map::clear() example

php
<?php
$map = new \Ds\Map([
    "a" => 1,
    "b" => 2,
    "c" => 3,
]);
print_r($map);

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

The above example will output something similar to:

output
Ds\Map Object
(
    [0] => Ds\Pair Object
        (
            [key] => a
            [value] => 1
        )

    [1] => Ds\Pair Object
        (
            [key] => b
            [value] => 2
        )

    [2] => Ds\Pair Object
        (
            [key] => c
            [value] => 3
        )

)
Ds\Map Object
(
)

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