PHP SplHeap rewind() Function Last Updated : 24 Mar, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report The SplHeap::rewind() function is an inbuilt function in PHP that is used to rewind the iterator to the beginning. 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. Syntax: void SplHeap::rewind() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs illustrate the SplHeap::rewind() function in PHP. Example 1: PHP <?php // Create a new empty Max Heap $heap = new SplMaxHeap(); $heap->insert('System'); $heap->insert('GFG'); $heap->insert('ALGO'); $heap->insert('C'); $heap->insert('Geeks'); $heap->insert('GeeksforGeeks'); // Use rewind() function $heap->rewind(); // Display the current element var_dump($heap->current()); ?> Output: string(6) "System" Example 2: PHP <?php // Create a new empty Min Heap $heap = new SplMinHeap(); $heap->insert('System'); $heap->insert('GFG'); $heap->insert('ALGO'); $heap->insert('C'); $heap->insert('Geeks'); $heap->insert('GeeksforGeeks'); // Use rewind() function $heap->rewind(); // Display the current element var_dump($heap); ?> Output: object(SplMinHeap)#1 (3) { ["flags":"SplHeap":private]=> int(0) ["isCorrupted":"SplHeap":private]=> bool(false) ["heap":"SplHeap":private]=> array(6) { [0]=> string(4) "ALGO" [1]=> string(1) "C" [2]=> string(3) "GFG" [3]=> string(6) "System" [4]=> string(5) "Geeks" [5]=> string(13) "GeeksforGeeks" } } Reference: https://www.php.net/manual/en/splheap.rewind.php Comment More infoAdvertise with us Next Article PHP | rewinddir() Function A ashokjaiswal Follow Improve Article Tags : Web Technologies PHP PHP-function Similar Reads PHP | rewind( ) Function The rewind() function in PHP is an inbuilt function which is used to set the position of the file pointer to the beginning of the file. Any data written to a file will always be appended if the file is opened in append ("a" or "a+") mode regardless of the file pointer position. The file on which the 2 min read PHP SplFixedArray rewind() Function The SplFixedArray::rewind() function is an inbuilt function in PHP which is used to rewind the array iterator to start position. Syntax: void SplFixedArray::rewind() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below programs illustr 1 min read PHP SplObjectStorage rewind() Function The SplObjectStorage::rewind() function is an inbuilt function in PHP which is used to rewind the iterator to the first storage element. Syntax: void SplObjectStorage::rewind() Parameters: This function does not accept any parameter. Return Value: This function does not return any value. Below progr 1 min read PHP | rewinddir() Function The rewinddir() function is an inbuilt function in PHP which is used to rewind the directory handle. The rewinddir() function opens a directory and list its files, resets the directory handle, list its files once again, then finally closes the directory handle. The directory handle sent as a paramet 2 min read PHP | SimpleXMLIterator rewind() Function The SimpleXMLIterator::rewind() function is an inbuilt function in PHP which is used to rewind the SimpleXMLIterator to the first element. Syntax: void SimpleXMLIterator::rewind( void ) Parameters: This function does not accept any parameters. Return Value: This function does not return any value. B 1 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 Like