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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.