From the course: Learning the Standard PHP Library
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Combining iterators with AppendIterator - PHP Tutorial
From the course: Learning the Standard PHP Library
Combining iterators with AppendIterator
- As its name suggest, the Append Iterator class appends iterators one right after another. So, they run consecutively. To demonstrates its use, I've opened append.php, which confined in the Chapter 4 folder of the exercise files. This file contains the definition of Author Filer, that's the custom class that extends filter iterator that we created in Chapter 3. Then on line 18, the data in course is .XML is loaded as simple XML. We'll use the Author Filter class to select courses by a couple of authors. So, we first need to add simple XML iterator and the second argument to simple XML load file. That enables us to use it as an iterator. Then, we'll create a couple of iterators to select courses by me and Jon Peck. So, Powers new Author Filter repass it a simple XML iterator courses, and then the second argument is the name of the author, that's me David Powers. Then, another one for Jon Peck, new author filter. the same courses iterator, and then Jon's name. We could iterator over…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.