Comfortable directory contents with filters


/ Published in: PHP
Save to your folder(s)

Very simple to use.

**Calling:**

$files = dirContents(DIR_PATH, [FILTER, [TYPE]]);

**Examples:**

$files = dirContens("my-dir");
_$files_ is array containing all, both files either directories

$files = dirContens("my-dir", "img[0-9]");
_$files_ is array containing files or directories with 'img0', 'img1', 'img2', etc. in their names

$files = dirContents("my-dir/", "\.php", 1);
_$files_ is array containing only files with '.php' in their names

**Tip:**
After calling _dirContents()_ try to call *print_r* for showing the array of files

echo '<pre>';
print_r($files);
echo '</pre>';

Thank you for your comments.

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.