Author Topic: Recursively display directory help  (Read 139 times)

0 Members and 1 Guest are viewing this topic.

Offline JD*Topic starter

  • Enthusiast
  • Posts: 217
  • Gender: Male
    • View Profile
Recursively display directory help
« on: March 17, 2010, 03:12:53 PM »
Hey everyone,

I'm trying to write a piece of code that will allow me to recursively look through a directory and list contents. I've tried a bunch of pre-made scripts but nothing is working correctly so far and I'm spent trying to figure it out.

What we have is a list of students that a teacher can click on an individual student, and then see different documents that have been uploaded from previous years. On the file system, they're stored in a path like:
/srv/www/website.com/files/student_number/2008-2009/language_arts/entry1.pdf
/srv/www/website.com/files/student_number/2008-2009/language_arts/entry2.pdf

What I'm looking to have is each directory from the year on down as an <h3> which I can then use some jquery to either make an accordion or some other effect, so the teachers can drill down. I was able to get the year to work, but everything below, not so much, as the looping wasn't being very flexible.

Also, when putting all of this into an array, it would list entry2 first, then entry1. I want to sort the array, but since it's all contained in one giant array, sorting just screws it all up.

Thanks for any help!
-- Don't forget: Mark your posts as solved when they are! --