• PHP Video Tutorials

PHP - Ds Map hasKey() Function



Ds\Map::hasKey() function can determine whether the map contain a given key.

Syntax

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

Ds\Map::hasKey() function can return true if the key found, or false otherwise.

Example 1

<?php
   $map = new \Ds\Map(["1" => 10, "2" => 20, "3" => 30]); 
  
   var_dump($map->hasKey("2")); 
?>

Example 2

<?php 
   $map = new \Ds\Map(["Tutorials" => "1", "Point" => "2", "India" => "3"]); 
  
   var_dump($map->hasKey("India")); 
?>
php_function_reference.htm
Advertisements