当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


PHP Ds Set count()用法及代码示例



Ds\Set::count() 函数可用于计算集合中存在的值的数量,也称为集合实例的大小。

用法

public int Ds\Set::count()

Ds\Set::count() 函数没有任何参数。

Ds\Set::count() 函数可以返回集合中存在的值的数量。

例子1

<?php  
   $set = new \Ds\Set([10, 15, 20, 25]);  
   var_dump($set);  
   
   echo "The count is:"; 
   print_r($set->count()); 
?>

例子2

>?php  
   $set = new \Ds\Set(["Tutorials", "Point", "India"]);  
   var_dump($set);  
   
   echo "The count is:"; 
   print_r($set->count()); 
?>

相关用法


注:本文由纯净天空筛选整理自 PHP - Ds Set count() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。