HH\Map::containsKey

Determines if the specified key is in the current Map

public function containsKey(
  mixed $key,
): bool;

This function is interchangeable with contains().

Guide

Parameters

  • mixed $key

Returns

  • bool - true if the specified key is present in the current Map; returns false otherwise.

Examples

$m = Map {
  'red' => '#ff0000',
  'green' => '#00ff00',
  'blue' => '#0000ff',
  'yellow' => '#ffff00',
};

// Prints "true", since key "red" is the first key
\var_dump($m->containsKey('red'));

// Prints "true", since key "yellow" is the last key
\var_dump($m->containsKey('yellow'));

// Prints "false", since key "blurple" isn't in the Map
\var_dump($m->containsKey('blurple'));