looking for some logic

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

looking for some logic

Post by s.dot »

I have a folder containing a lot of directories.

The directories are named for each member that has signed up on my site.

Before I had my deletion set up properly, some people deleted their accounts and their pictures and directories are still on my server wasting space.

How could I loop through the usernames and find only the directories that are not found in the username database?

I'm not looking for a code that would delete them, just echo them to me so I can do it manually. I'd prefer to do it that way.

Could someone give me some logic?
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Use opendir() and is_dir() to traverse through directory names within a directory.

For your usernames stored in the database you'll need to query it and check each username's directory.
Sort it to save time.

Otherwise - if your usernames are less than 1000 - you can have the directory names in an array and the usernames from the database in another array and use array_diff_assoc() to find out the difference.
Post Reply