- We've created a priority queue that sorts…the php error log according to the error level,…with fatal errors first, followed by warnings,…and then less important errors.…The SplPriorityQueue class is implemented…using a max heap, so items of the same priority…are not listed in any particular order.…If you want to preserve the original order…within each priority group, you need to…extend the SplpPriorityQueue class.…This solution incidentally was published anonymously…in the user notes of the PHP online documentation.…
So whoever came up with it deserves a vote of thanks.…This is priority_order.php which you can…find in the chapter seven folder of the exercise files.…It contains exactly the same code as…at the end of the previous video.…So what we need to do is to extend SplPriorityQueue.…Let's do that at the top of the file.…So type in a couple of lines on line two…and then we'll call the class OrderedPriority…and it extends SplPriorityQueue.…
To preserve the original order, we need to start…with a very large number and decrease it each time…
Author
Released
10/22/2014- Using SPL iterators
- Inspecting directories
- Working with text files
- Exporting and extracting data
- Filtering data
- Converting between arrays and iterators
- Combining and merging iterators
- Creating a repeat sequence with InfiniteIterator
- Working with data structures
Skill Level Intermediate
Duration
Views
Related Courses
-
Advanced PHP: Debugging Techniques
with Jon Peck1h 29m Intermediate -
PHP: Exporting Data to Files
with David Powers3h 42m Intermediate
-
Introduction
-
Welcome59s
-
-
1. Introducing the Standard PHP Library (SPL)
-
Introducing SPL iterators1m 59s
-
Using SPL iterators2m 6s
-
2. Exploring Files and Directories
-
3. Filtering Values
-
4. Array Iterators
-
Filtering values from JSON4m 45s
-
5. Combining and Merging Iterators
-
6. Other Iterators
-
7. SPL Data Structures
-
Using SplStack and SplQueue6m 25s
-
Understanding heaps2m 55s
-
Conclusion
-
Goodbye1m 37s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Keeping priority items in chronological order