• PHP Video Tutorials

PHP - Ds Map first() Function



Ds\Map::first() function can return the first pair in a map.

Syntax

public Ds\Pair Ds\Map::first( void )

Ds\Map::first() function doesn't have any parameters.

Ds\Map::first() function can return the first pair in a map and throw UnderflowException if empty.

Example 1

<?php 
   $map = new \Ds\Map([1 => "Tutorials", 2 => "Point", 3 => "India"]); 
   print_r($map->first()); 
?>

Example 2

<?php 
   $map = new \Ds\Map(["first" => "Tutorials", "second" => "Point", "third" => "India"]); 
   print_r($map->first());
?>
php_function_reference.htm
Advertisements