Soldato
- Joined
- 27 Dec 2005
- Posts
- 17,317
- Location
- Bristol
What I'm trying to do is quite basic, and yet it's throwing up a load of problems.
I have a list of files...
200507July 2005.html
200508August 2005.html
200509September 2005.html
etc.
...and I want to display these as a list, but obviously earliest first. The code I'm using is:
It seems fairly straight forward, but the result is not so much. At the moment it's returning:
Array ( [0] => 200601January 2006.html [1] => 200602February 2006.html [2] => 200510October 2005.html [3] => 200511November 2005.html [4] => 200509September 2005.html [5] => 200507July 2005.html [6] => 200508August 2005.html )
Which is fine apart from Jan/Feb and July/Aug, and I have no idea why it's putting them in this order.
Any help greatly appreciated!
I have a list of files...
200507July 2005.html
200508August 2005.html
200509September 2005.html
etc.
...and I want to display these as a list, but obviously earliest first. The code I'm using is:
PHP:
$path = "/";
$dir_handle = @opendir($path) or die("Unable to open $path");
while ($file = readdir($dir_handle))
{
if($file!="." && $file!=".." && $file!="index.php" && $file!="inc.php"){
$dir_array[] = $file;
}
}
closedir($dir_handle);
$dir_reversed = array_reverse($dir_array);
foreach($dir_reversed as $key => $value){
$newfile = substr($value, 6, -5);
echo "<div class='readMoreBtn' style='margin-right:10px'><a href='$newfile'>$newfile</a></div>";
}
Array ( [0] => 200601January 2006.html [1] => 200602February 2006.html [2] => 200510October 2005.html [3] => 200511November 2005.html [4] => 200509September 2005.html [5] => 200507July 2005.html [6] => 200508August 2005.html )
Which is fine apart from Jan/Feb and July/Aug, and I have no idea why it's putting them in this order.
Any help greatly appreciated!
Last edited: