Jump to content

List contents


vantheman

Recommended Posts

Hi,

What's the best way to list the contents of multiple subdirectory in one list?

For example:

On the site, there's a "secure" folder which contains several subfolders (week_of_1-22-09, week_of_1-29-09, etc.). Each folder contains mp3 files.

a.) I would like to populate a list, on the "home" page (which is not inside the 'secure' folder), that will show the Artist, Title, Genre & which folder it resides in.

b.) Secondly, I would also like to be able to search by (artist, title, etc.).

c.) The items on this list are for vewing ONLY (not clickable).

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/156553-list-contents/
Share on other sites

1) and 2) can't help you with 3rd

 

<?php
function scandir_r($directory) {
    $scanned_files = array();
    $files = scandir($directory);
    foreach ($files as $file) {
        if (is_dir($file)) {
            $scanned_files[] = scandir_r($file);
        } else {
            $scanned_files[] = $file;
        }
    }
    return $scanned_files;
}

function search_r($filename, $directory) {
    $result = array();
    $files = scandir_r($directory);
    foreach ($files as $file) {
        if (is_array($file)) {
            $result[] = search_r($filename, $file);
        } else if (strpos($file, $filename) !== false) {
            $result[] = $file;
        }
    }
    return $result;
}
?>

Link to comment
https://forums.phpfreaks.com/topic/156553-list-contents/#findComment-824301
Share on other sites

  • 2 weeks later...

I know it has been a few weeks since the reply was posted to my post. My appologies.

 

When I test this script, it comes up as a blank page. Could it be that no particular directory is specified? If so, where/how do I specify the desired folder/subfolders to return?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/156553-list-contents/#findComment-835326
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.