PHP | SplHeap current() Function Last Updated : 28 Jun, 2019 Comments Improve Suggest changes Like Article Like Report 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. 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: mixed SplMaxHeap::current() Parameters: This function does not accept any parameter. Return Value: This function returns current node of heap data structure. Below programs illustrate the SplMaxHeap::current() function in PHP: Program 1: php <?php // Create a new empty Max Heap $heap = new SplMaxHeap(); $heap->insert('System'); $heap->insert('gfg'); $heap->insert('ALGO'); $heap->insert('C'); // Move next node $heap->next(); $heap->next(); echo $heap->current() . "\n"; ?> Output: C Program 2: php <?php // Create a new empty Max Heap $heap = new SplMaxHeap(); $heap->insert('GEEKS'); $heap->insert('gfg'); $heap->insert('DSA'); $heap->insert('ALGO'); $heap->insert('C'); // Iterate array and print values while($heap->valid()) { // Print current value of index of the array echo $heap->current(). "\n"; // Move next each time of iteration $heap->next(); } ?> Output: gfg GEEKS DSA C ALGO Reference: https://www.php.net/manual/en/splheap.current.php Comment More infoAdvertise with us Next Article PHP | SplHeap current() Function R R_Raj Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads 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 PHP SplFixedArray current() Function The SplFixedArray::current() function is an inbuilt function in PHP which is used to get the current entry of the array. Syntax: mixed SplFixedArray::current() Parameters: This function does not accept any parameter. Return Value: This function returns the current entry of the array. Below programs 1 min read PHP current() Function The current() function is an inbuilt function in PHP. It is used to return the value of the element in an array which the internal pointer is currently pointing to.The current() function does not increment or decrement the internal pointer after returning the value.In PHP, all arrays have an interna 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 Like