PHP Ds\Set count() Function Last Updated : 22 Aug, 2019 Comments Improve Suggest changes Like Article Like Report The Ds\Set::count() function of Ds\Set class in PHP is an inbuilt function which is used to count the number of values present in the Set. This is also referred to as the size of the Set instance. Syntax: int public Ds\Set::count() Parameters: This function does not accept any parameter. Return Value: This function returns the number of values present in a Set instance. Below programs illustrate the Ds\Set::count() function: Program 1: php <?php // Declare new Set $set = new \Ds\Set([10, 15, 21]); // Display the Set element var_dump($set); // Display count of elements // present in the Set echo "Count is : "; print_r($set->count()); ?> Output: object(Ds\Set)#1 (3) { [0]=> int(10) [1]=> int(15) [2]=> int(21) } Count is : 3 Program 2: php <?php // Declare new Set $set = new \Ds\Set(["Geeks", "for", "Keegs"]); // Display the Set element var_dump($set); // Display count of elements // present in the Set echo "Count is : "; print_r($set->count()); ?> Output: object(Ds\Set)#1 (3) { [0]=> string(5) "Geeks" [1]=> string(3) "for" [2]=> string(5) "Keegs" } Count is : 3 Reference: http://php.net/manual/en/ds-set.count.php Comment More infoAdvertise with us Next Article PHP count() Function G gopaldave Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-ds_set Similar Reads PHP DsSet count() Function The Ds\Set::count() function of Ds\Set class in PHP is an inbuilt function which is used to count the number of values present in the Set. This is also referred to as the size of the Set instance. Syntax: int public Ds\Set::count() Parameters: This function does not accept any parameter. Return Valu 1 min read PHP count() Function The count() function in PHP is used to count the number of elements in an array or the countable properties of an object. The function returns an integer value representing the number of items present.Syntax:count($array, mode)In this syntax:$array (mandatory): Refers to the array, whose elements ar 3 min read PHP substr_count() Function The substr_count() is a built-in function in PHP and is used to count the number of times a substring occurs in a given string. The function also provides us with an option to search for the given substring in a given range of the index. It is case sensitive, i.e., "abc" substring is not present in 3 min read PHP | DsStack count() Function The Ds\Stack::count() function is an inbuilt function in PHP which is used to count the number of elements present in the Stack. Syntax: int Ds\Stack::count( void ) Parameters: This function does not accept any parameter. Return Value: This function returns the number of elements present in the Stac 1 min read PHP DsQueue count() Function The Ds\Queue::count() Function in PHP is used to get the count of elements present in a Queue instance. Syntax: int public Ds\Queue::count ( void ) Parameters: This function does not accepts any parameters. Return Value: This function calculates the number of elements present in a Queue instance and 1 min read PHP | SplHeap count() Function The SplHeap::count() function is an inbuilt function in PHP which is used to count the elements in the heap. Generally, Heap can be of two types: Max-Heap: In a Max-Heap the key present at the root node must be greatest among the keys present at all of its children. The same property must be recursi 2 min read Like