PHP Snippet:
Recursive Directory Browser
Posted on Aug 20, 2006 12:32 am
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
Example: /home/tye//file is the same as /home/tye/file
PHP Snippet:
Recursive Directory Browser
Posted on Aug 13, 2006 7:46 am
Posted on Aug 13, 2006 7:46 am
Please check for a slash when you submit a path with an slash at the end.
PHP Snippet:
Recursive Directory Browser
Posted on Sep 8, 2005 9:35 pm
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 = "^[^.]*$"; }
function directoryToArray($directory, $extension = false, $full_path = true) {
if ($extension !== false && strlen($extension)) { $extension = "\.$extension"; }
elseif ($extension !== false && !strlen($extension)) { $extension = "^[^.]*$"; }
PHP Snippet:
Recursive Directory Browser
Posted on Sep 8, 2005 9:33 pm
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.
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.
PHP Snippet:
Extract Alpha Numeric Characters
Posted on Aug 31, 2005 2:55 am
Posted on Aug 31, 2005 2:55 am
Very handy!
PHP Snippet:
YYYY-MM-DD Date Conversion Version 2
Posted on May 29, 2005 12:25 am
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.
PHP Snippet:
YYYY-MM-DD Date Conversion Version 2
Posted on Mar 12, 2005 2:15 am
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





