Ayush123 Posted January 1, 2023 Share Posted January 1, 2023 I need to make array using dates created of files for a directory. lets say i have a folder with files, now i need the dates created of all those files into an array. Quote Link to comment https://forums.phpfreaks.com/topic/315749-array-help/ Share on other sites More sharing options...
ginerjm Posted January 1, 2023 Share Posted January 1, 2023 OK - write some code and see what happens. Bye Quote Link to comment https://forums.phpfreaks.com/topic/315749-array-help/#findComment-1604104 Share on other sites More sharing options...
Moorcam Posted January 3, 2023 Share Posted January 3, 2023 Already asked for it here Quote Link to comment https://forums.phpfreaks.com/topic/315749-array-help/#findComment-1604131 Share on other sites More sharing options...
ginerjm Posted January 3, 2023 Share Posted January 3, 2023 I know the OP has 'asked'. We are here to help posters with problems with the code the write for themselves. Hence my last post - show us please. Quote Link to comment https://forums.phpfreaks.com/topic/315749-array-help/#findComment-1604142 Share on other sites More sharing options...
Barand Posted January 3, 2023 Share Posted January 3, 2023 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. Quote Link to comment https://forums.phpfreaks.com/topic/315749-array-help/#findComment-1604150 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.