Ds\Map::first

(PECL ds >= 1.0.0)

Ds\Map::firstReturns the first pair in the map

說明

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

Returns the first pair in the map.

參數(shù)

此函數(shù)沒有參數(shù)。

返回值

The first pair in the map.

錯誤/異常

UnderflowException if empty.

范例

示例 #1 Ds\Map::first() example

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

以上例程的輸出類似于:

object(Ds\Pair)#2 (2) {
  ["key"]=>
  string(1) "a"
  ["value"]=>
  int(1)
}