Jump to content

Problem with some foreach() and some glob()


arbitter

Recommended Posts

I want to display all directorys;

the file is in a folder, let's say folder A.

In folder A, theres the directory 'fotos'

In that directory are years, as '2010'

in that folder, there are months 'January'

 

For each month of each year, I want a table line.

 

The problem is that with what I have now, I get all the folders from in 2010, but then when I loop I get all the folders from 2010 again and then the folders from 2011.

$diryear = GLOB('fotos/*', GLOB_ONLYDIR);
foreach($diryear as $diryears){
$dirmonth = GLOB($diryears . '/*', GLOB_ONLYDIR);
foreach($dirmonth as $dirmonthh){
	$dirsorted[filemtime($dirmonthh)] = $dirmonthh;
}
ksort($dirsorted);			
foreach($dirsorted as $dirmonths){
	$dirmonthss = urlencode($dirmonths);
	$stuk = explode('/',$dirmonths);
	echo "<tr><td align='center' style='cursor:pointer' colspan='2' bgcolor='white' onclick=\"location.href='index.php?module&#61;fotos&dir&#61;$dirmonthss'\">$stuk[2] $stuk[1]</td></tr>";
}
}

 

Link to comment
https://forums.phpfreaks.com/topic/196690-problem-with-some-foreach-and-some-glob/
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.