« Ds\Map::get
Ds\Map::hasValue »

Ds\Map::hasKey

(PECL ds >= 1.0.0)

Ds\Map::hasKey — Determines whether the map contains a given key

説明

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

Determines whether the map contains a given key.

パラメータ

key

The key to look for.

戻り値

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

例

例1 Ds\Map::hasKey() example

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

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

上の例の出力は、 たとえば以下のようになります。

bool(true)
bool(false)
関連キーワード:
hasKey   Determines   whether   contains   given   dump   hasValue   mixed   look   found   otherwise   example
関連する関数・ページ:
ds-map.hasvalue   ds-set.contains   ds-vector.contains   ds-sequence.contains   ds-deque.contains   ds-map.get