Implementing priority queue in PHP
PHP , programming concepts / June 2, 2018

Queue is a First In First Out(FIFO) Data Structure.In a priority queue, an element with high priority is served before an element with low priority.The Standard PHP Library has the SplPriorityQueue class which can be used to implement priority queue.The insert(‘item’,priority) method is used to insert item and the corresponding priority in to the queue.See the below example to see mail sending to different mail id’s that have different priorities.You can use while to iterate thorough the queue and process each one or the results. SplPriorityQueue A priority queue can be implemented using many of the data structures that we’ve already studied (array, inked list, binary search tree). However, those data structures do not provide the most efficient operations. To make all of the operations  efficient, heap can be used . SplPriorityQueue is implemented using Max Heap


Javascript snippet for extracting image (url) from string – regex
Javascript / June 2, 2018

Consider the following string

The above code extracts all the images in the string  as an array and we take  one from it;  

Share this page in social media platforms