Here's what I have so far:
Code: Select all
<?php
if ($handle = opendir('sermons')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$apostrophe = str_replace("'","'",$file);
$base = basename($file,".txt");
$explode = explode( ", ", $base);
echo $explode[1];
echo "<br>";
// echo "<a href='sermons/$apostrophe'>$base\n</a><br>";
}
}
closedir($handle);
}
?>
I'm using explode() to get the dates in the filename of my files separate so I can sort by the date. For example:
file1, 09-23-2009.txt => 09-23-2009
file2, 08-25-2007.txt => 08-25-2007
file2, 02-23-2010.txt => 02-23-2010
With the coding above, I was able to get it to just echo the date. Now, how can I turn the string into an actual, recognized date so then I could use some sort of "sort" command to sort it by date, while still echoing the full file name minus the ".txt"? Any help will be appreciated it. Thank you so much in advance for help!