3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pq = new SplPriorityQueue(); //insert method inserts an element in the queue by shifting it up $pq->insert('A', 3); $pq->insert('B', 6); $pq->insert('C', -1); $pq->insert('D', 2); //count the elements echo "count ->" . $pq->count(); //Sets the mode of extraction (EXTR_DATA, EXTR_PRIORITY, EXTR_BOTH) $pq->setExtractFlags(SplPriorityQueue::EXTR_BOTH); //go at the node from the top of the queue $pq->top(); //iterate the queue (by priority) and display each element while ($pq->valid()) { print_r($pq->current()); $pq->next(); }
Output for git.master, git.master_jit, rfc.property-hooks
count ->4Array ( [data] => B [priority] => 6 ) Array ( [data] => A [priority] => 3 ) Array ( [data] => D [priority] => 2 ) Array ( [data] => C [priority] => -1 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
43.24 ms | 401 KiB | 8 Q