Good day everyone ,
My frist post hopefully not my last , i'm new php explorer.
I need a help on small project , i need a simple code that i enter a date and when i click on a button let's say RUN it will look in a drive:let's say path and will seach for a value , if if it does not find the searched value , will show me a small report about the search that was not found.
Please if you could just guide me with simple search Example :
Input the date wanted for the searched value
and Click on RUN to seach for all the files in a specific folders - examples
c:\1001\100111172009.txt
c:\1002\100211172009.txt
and so on ...
Please note that i have to do a search everyday for these files.
the files prefix (X) will change everyday1001xxxxxx.txt where x is the date MMDDYYYY
The files that i have in my drives are named as this : 100111172009.txt
1001 department #
11172009 date created
.txt the extension for the file.
I have 100 department that i need to search everyday.
Please help me it's a crucial for me as i was asked to start this small project and i'am idiot in PHP ...
A family man who does not wanna loose his Job ...home ...and Wife.
Help Suggestions - Simple PHP code
Moderator: General Moderators
Re: Help Suggestions - Simple PHP code
Anyone please ?
Thank you.
Thank you.
- BlaineSch
- Forum Commoner
- Posts: 28
- Joined: Sun Jun 07, 2009 4:28 pm
- Location: Trapped in my own little world.
Re: Help Suggestions - Simple PHP code
You'd want to start at the root, make a recursive function to transverse through the directories and search for the date in the file name.
Code: Select all
//untested
function searchFile($dir, $name) {
$files = scandir($dir);
foreach($files as $file) {
if(is_dir($file)) {
searchFile("{$dir}/{$file}", $file);
} else {
if($file==$name) {
echo "Found: {$file}";
}
}
}
}