The SplPriorityQueue::current() function is an inbuilt function in PHP which is used to return the current node pointed by the iterator.
Syntax:
mixed SplPriorityQueue::current()
Parameters: This function does not accept any parameter.
Return Value: This function returns the value/priority of the current node depending on the extract flag.
Example:
PHP
| <?php  // Declare a class classpriorityQueue extendsSplPriorityQueue {          // Compare function to compare priority     // queue elements     publicfunctioncompare($p1, $p2) {         if($p1=== $p2) return0;         return$p1< $p2? -1 : 1;     } }  // Create an object of priority queue $obj= newpriorityQueue();  // Insert elements into the queue $obj->insert("Geeks",2); $obj->insert("GFG",1); $obj->insert("G4G",3); $obj->insert('G',4);  // Display the current element // of priority queue print_r($obj->current());  ?> | 
G
Reference: https://www.php.net/manual/en/splpriorityqueue.current.php


 
                                    







