I understand glob() can pull up the actual files in a directory, but if I wanted to pulll the files only if the date on them were say, in-between, a three day range, could I use preg_match or some preg function.
Please do not write the code, I need to get better I will post my makeshift crap code later when its written, and see if anyone is kind enough to helpme debug it. Thank you for any help and/or suggestions you can provide.
Loop through a directory of files
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
no need for preg_*, filemtime()
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
Yea
That really is a nice code. However it kinda goes away from my exact purpose, plus i'd rather try to do this myself, at least a draft of the code. I got something that i'm going to post up in a second here.
- akimm
- Forum Contributor
- Posts: 460
- Joined: Thu Apr 27, 2006 10:50 am
- Location: Ypsilanti Michigan, formally Clipsburgh
Date comparison question
Ok, my purpose for this code is to read $path variable, enter that directory, view the creation time of the files, if they are lesser than 6 days I want them to echo out with the foreach loop that will then print new articles.
this is the error I'm getting
"Parse error: parse error, unexpected $ in /nfs/cust/8/25/05/650528/web/toop.php on line 21"
toop.php
this is the error I'm getting
"Parse error: parse error, unexpected $ in /nfs/cust/8/25/05/650528/web/toop.php on line 21"
toop.php
Code: Select all
<table>
<tr>
<?php
$path = "advertisements/";
if (is_dir("$path"))
{
$handle = opendir($path);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$Diff = (time() - filectime("$path/$file"))/60/60/24;
if ($Diff > 6) {
foreach($path/$file as $key) {
echo "<td>" . "new articles" . $key . "</tr>";
}
}
}
closedir($handle);
}
?>
</tr></table>