News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

NETTUTS.com:
Quick Tip Loop Through Folders with PHP's Glob()
April 27, 2010 @ 11:49:15

Sometimes when you're looking through the filesystem in your PHP application, you just need a quick and easy way to grab a file listing from a directly and move on. Sure, you can use the usual opendir and readdir combo to loop through the files, but there's another function that might suit your needs better - glob. In this quick tutorial from NETTUTS.com today they show you how it works.

Are you still using opendir() to loop through folders in PHP? Doesn't that require a lot of repetitive code everytime you want to search a folder? Luckily, PHP's glob() is a much smarter solution.

They include code examples showing how the usual opendir/readdir code can be translated over to an example using glob and mention the two arguments you can use - a pattern-matching search string and a modifier to change settings on the search and on the results returned.

0 comments voice your opinion now!
glob tutorial loop filesystem opendir readdir


blog comments powered by Disqus

Similar Posts

DevShed: Fetching Search Results as Serialized Arrays with Yahoo Web Services and PHP 5

Rob Morgan's Blog: Howto Log Directly to Your OS X Terminal using Zend Framework and NodeJS

Community News: Symfony Framework Makes Some Updates (v.0.6.2 and Content)

Brian Swan's Blog: SQL Server Driver for PHP Connection Options: Transaction Isolation Levels

DevShed: The Basics of Abstract Factory Classes in PHP 5


Community Events





Don't see your event here?
Let us know!


list framework interview podcast language code series release configure community testing opinion introduction threedevsandamaybe install unittest refactor laravel wordpress developer

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework