Welcome Guest, Not a member yet? Register   Sign In
issues with using the directory_map() with foreach
#1

[eluser]ggoforth[/eluser]
As the title suggests, I'm having an issue looping over the return of directory_map() in a foreach loop. My code looks something like:

Code:
$dirMap = directory_map($path);

//loop over the map, creating the proper class instances for each
//element in the $map
foreach ($dirMap as $dir => $files) {
    //do stuff
}

I'm setting up a "gallery" type of site, where a gallery might have sub-galleries, etc... When I try and loop over the $dirMap using foreach the following error is generated:

Quote:A PHP Error was encountered

Severity: Warning

Message: Invalid argument supplied for foreach()

Filename: libraries/lib_gallery.php

Line Number: 26

If I print_r $dirMap it does indeed look like an array, the output looks like:

Quote:Array
(
[0] => hairfire.jpeg
[1] => goat.jpg
[someDir] => Array
(
[0] => j.jpg
)

)

Any ideas why php doesn't like $dirMap in my foreach?




Theme © iAndrew 2016 - Forum software by © MyBB