PHP | SplHeap count() Function Last Updated : 28 Jun, 2019 Comments Improve Suggest changes Like Article Like Report 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 recursively true for all sub-trees in that Binary Tree. Min-Heap: In a Min-Heap the key present at the root node must be minimum among the keys present at all of its children. The same property must be recursively true for all sub-trees in that Binary Tree. Note: This article uses Max Heap which extends the SplHeap class. Syntax: int SplMaxHeap::count() Parameters: This function does not accept any parameter. Return Value: This function returns the number of nodes present in heap. Below programs illustrate the SplMaxHeap::count() function in PHP: Program 1: php <?php // Create a new empty Max Heap $heap = new SplMaxHeap(); $heap->insert('GEEKS'); $heap->insert('gfg'); // Print Result echo $heap->count(); ?> Output: 2 Program 2: php <?php // Create a new empty Max Heap $heap = new SplMaxHeap(); // Print Result echo $heap->count() . "\n"; $heap->insert('GEEKS'); $heap->insert('gfg'); $heap->insert('DSA'); $heap->insert('ALGO'); $heap->insert('C'); // Print Result echo $heap->count(); ?> Output: 0 5 Reference: https://www.php.net/manual/en/splheap.count.php Comment More infoAdvertise with us Next Article PHP | SplHeap count() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | SplHeap current() Function The SplHeap::current() function is an inbuilt function in PHP which is used to get the current element pointed by the iterator. Generally, the Heap Data Structure are 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 2 min read PHP SplHeap __construct() Function The SplHeap::__construct() function is an inbuilt function in PHP that is used to create the heap data structure. Generally, the Heap Data Structure are 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 pr 2 min read PHP SplHeap extract() Function The SplHeap::extract() function is an inbuilt function in PHP which is used to extract a node from top of the heap and sift up. Generally, the Heap Data Structure are 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 childre 1 min read PHP SplFixedArray count() Function The SplFixedArray::count() function is an inbuilt function in PHP which is used to return the size of the array. Syntax: int SplFixedArray::count() Parameters: This function does not accept any parameter. Return Value: This function returns the size of the array. Below programs illustrate the SplFix 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 ZipArchive count() Function The ZipArchive::count() function is an inbuilt function in PHP that is used to count the number of files in a zip archive.Syntax:int ZipArchive::count()Parameters: This function does not accept any parameters.Return Value:This function returns the number of files in the zip archive.Example 1: The fo 2 min read PHP SplHeap key() Function The SplHeap::key() function is an inbuilt function in PHP which is used to get the current node index. Generally, the Heap Data Structure are 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 2 min read PHP SplHeap top() Function The SplHeap::top() function is an inbuilt function in PHP that is used to display the peek node from the top of the heap. Generally, the Heap Data Structure is 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 s 2 min read PHP SplObjectStorage count() Function The SplObjectStorage::count() function is an inbuilt function in PHP which is used to count the number of objects in storage. Syntax: int SplObjectStorage::count() Parameters: This function does not contains any parameter. Return Value: This function returns number of objects in storage. Below progr 1 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 Like