當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP Ds Map first()用法及代碼示例


Ds\Map::first() 函數可以返回映射中的第一對。

用法

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

Ds\Map::first() 函數沒有任何參數。

Ds\Map::first() 函數可以返回映射中的第一對,如果為空則拋出 UnderflowException。

例子1

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

例子2

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

相關用法


注:本文由純淨天空篩選整理自 PHP - Ds Map first() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。