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

PHPCodeBase.com:
PHP Magic Function : glob()
Apr 01, 2011 @ 13:21:20

On PHPCodeBase.com there's a recent post looking at a handy file system function that you can use to search directories simpler than a usual opendir/readdir method - glob.

Are you guys still using opendir() function to read the the files from the folder in PHP? Luckily PHP have the glob() function which perform this task very faster and smarter.

He compares an example of the opendir/readdir method to a few line replacement with glob, both searching the same directory for files. He looks at the arguments you can pass into glob - the path to search and a flag that adds special handling to the method (like turning off sorting, modifying the regular expression handling and stopping on errors).

tagged: function glob opendir readdir regularexpression search

Link:

NETTUTS.com:
Quick Tip: Loop Through Folders with PHP’s Glob()
Apr 27, 2010 @ 16: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.

tagged: glob tutorial loop filesystem opendir readdir

Link:


Trending Topics: