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

Ds\Map::keys

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Returns a set of the map's keys

Description

Ds\Map::keys(): Ds\Set

Returns a set containing all the keys of the map, in the same order.

Parameters Parameters

Return Values

A Ds\Set containing all the keys of the map.

Examples

Ds\Map::keys() example

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

The above example will output something similar to:

output
object(Ds\Set)#2 (3) {
  [0]=>
  string(1) "a"
  [1]=>
  string(1) "b"
  [2]=>
  string(1) "c"
}

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