Jump to content

Recommended Posts

This will list download links for all the .log files in specified directory that have the specified filectime

$search_dir = 'c:/path/to/logs';
$search_date = '2023-01-03';

$files = glob("$search_dir/*.log");                                                  // find all .log file in search dir
$todays = array_filter($files, fn($v)=>date('Y-m-d',filectime($v))==$search_date);   // filter for date's files only
$names = array_map('basename', $todays);                                             // remove paths for display

if ($todays) {
    foreach ($todays as $k => $fn) {
        echo "<a href='$fn' download>$names[$k]</a><br>";
    }
}
else echo "No files found";

You might be better off using filemtime() if looking for the date's log entries.

Link to comment
https://forums.phpfreaks.com/topic/315749-array-help/#findComment-1604150
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.