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

Ds\Map::hasKey

PHP function Edit on GitHub ✎

(PECL ds >= 1.0.0)

Determines whether the map contains a given key

Description

Ds\Map::hasKey(mixed $key): bool

Determines whether the map contains a given key.

Parameters

key

The key to look for.

Return Values

Returns true if the key could be found, false otherwise.

Examples

Ds\Map::hasKey() example

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

var_dump($map->hasKey("a")); // true
var_dump($map->hasKey("e")); // false
?>

The above example will output something similar to:

output
bool(true)
bool(false)

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