GlobIterator: Easy access to specific files
For a project I am working on I needed to iterate over all .xml files in a specific directory. I started out with a DirectoryIterator, then considered I didn't want the XML filtering to take place inside my foreach loop. I decided to add a FilterIterator to the setup, but then felt this was not the right solution either. So I turned to my favorite SPL guru, Joshua Thijssen, to see if I was overseeing some kind of filter-option in the DirectoryIterator. I didn't, but I did oversee something else: GlobIterator.
GlobIterator exists since PHP5.3, and basically allows to iterator over anything glob()able. So instead of having to write my own custom FilterIterator and pass the DirectoryIterator for my directory to that FilterIterator, I can simple instantiate GlobIterator and pass the pattern that I need to it:
$watchDir = new \GlobIterator($config['incomingPath'].'/*.xml');
Now I can foreach over $watchDir and do whatever I need to do (in this case parse XML) with only a couple of lines of code! WIN!
Update: Davey rightfully asked "why not use glob() in the first place?". To clarify: I am using GlobIterator because I want to have SplFileInfo objects instead of just plain filenames. I need some of the meta info SplFileInfo offers.
April 16, 2012 - tags: php, globiterator, spl, directoryiterator, filteriterator, iterators
cd players multi disc
: cartoon style mp3 player description: a perfect mp3 for making a fashion statement. free tech gifts with special purchases at bose. disc jockey cd player, dual cd player, rack mountable cd player, rack mount cd player, dj rack mount cd player. the problem: enter the cd player (and mp3 player, and anything that operates *electronically* versus *mechanically*).
glutathione whitening pills with vitamin c
: according to nldontheweb.com, up to 80% of the people who meet the diagnostic criteria for asperger’s syndrome also have nonverbal learning disability. this is the biggest reason for the many requirements and demands placed on the student who is working toward a zoo career in this specialized carnivorous field. i live by the adage that most things that come from the ground are good for us so eat plenty of fruits and veges for great memory.
: allergy research group - nutricology (19). glutathione recycler. moreover, this will help keep your dog from begging for food every now and then. are nootropics safe? do they really work? where are the studies? and what are the cheapest ways to acquire them? in the coming weeks and months all shall be explained. natural liver flushes.
Snap Food Stamps Oregon
: please do not contact job poster about other services, products or commercial interests. wbc nuclear market group company profile in brighton, mi. visit flipdog for michigan school psychologist jobs, careers, and employment opportunities at flipdog. by greg on february 11th, 2012. the story may be different in. top ten culinary colleges in michigan. veteran and now quality dairy store manager steven goward is shown with lisa benson, quality dairys human relations director. lao british stranger donated kidney after meeting at a party. marysville jobs, employment indeed job search one search. abandons its plan for across the board pay raises.