Top

Comments

  (7)  RSS
dohdoh's
tye
Comments: 67
 
PHP Snippet:  Recursive Directory Browser
Posted on Aug 20, 2006 12:32 am
Adding an extra slash should not break paths
Example: /home/tye//file is the same as /home/tye/file
mfjtf
Comments: 1
 
PHP Snippet:  Recursive Directory Browser
Posted on Aug 13, 2006 7:46 am
Please check for a slash when you submit a path with an slash at the end.
tye
Comments: 67
 
PHP Snippet:  Recursive Directory Browser
Posted on Sep 8, 2005 9:35 pm
Forgot something in my comment:

function directoryToArray($directory, $extension = false, $full_path = true) {
if ($extension !== false && strlen($extension)) { $extension = "\.$extension"; }
elseif ($extension !== false && !strlen($extension)) { $extension = "^[^.]*$"; }

tye
Comments: 67
 
PHP Snippet:  Recursive Directory Browser
Posted on Sep 8, 2005 9:33 pm
This is a nice snippet but a a minor change that could improve it a bit. The extension could be treated differently so you can specify no extension and only grab files with no extensions. Would be easy to do like this:

function directoryToArray($directory, $extension = false, $full_path = true) {
if ($extension !== false && strlen($extension)) { $extension = "\.$extension"; }

And the if statement that checks for a condition:

if($extension !== false || (ereg("$extension\$", $file)))

Then leaving an empty string would return all files with no extensions, or specifying false (or leaving it empty) will return all files.
Hawkee
Comments: 588
 
PHP Snippet:  Extract Alpha Numeric Characters
Posted on Aug 31, 2005 2:55 am
Very handy!
Hawkee
Comments: 588
 
PHP Snippet:  YYYY-MM-DD Date Conversion Version 2
Posted on May 29, 2005 12:25 am
I don't think the echo is necessary. Maybe it'll be insert into a template or used in a mySQL query.
log2
Comments: 52
 
PHP Snippet:  YYYY-MM-DD Date Conversion Version 2
Posted on Mar 12, 2005 2:15 am
this only gets the date, it doesn't show it? you need an echo "$date"; in there
Bottom