Getting folder names in a master folder problem

I have a master folder called temp. In that folder I have many subfolders and in each of the sub folders I a folder called profile and in there I have many files.

My script processes the files in each of the sub folders. Doing this manually my script works fine.

What I want to do is to read the sub-folder names and then feed this folder name into my existing script to iterate through all the sub folders and process the files.

The code I currently have is

[php]
if ($handle = opendir(‘temp’)) {

while (false !== ($entry = readdir($handle))) {

$profile_dir=“temp/”.$entry."/profile/";

…rest of my code

[/php]

The error message I am getting is

Warning: file_get_contents(temp/./profile/about.txt)

So it looks like entry is being stored as . instead of the sub folder name.

Any clues as to what I am doing wrong please?

In linux you get

. = current folder
… = one folder up
files in current folder…

Thanks for the clue, just needed to add

[php]if ($entry != “.” && $entry != “…”) {[/php]

and that sorted it.

Sponsor our Newsletter | Privacy Policy | Terms of Service