• PHP Video Tutorials

PHP - Ds Set count() Function



Ds\Set::count() function can be used to count the number of values present in a set, and also referred to as the size of a set instance.

Syntax

public int Ds\Set::count()

Ds\Set::count() function doesn't have any parameters.

Ds\Set::count() function can return the number of values present in a set.

Example 1

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

Example 2

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