Page 1 of 1

Help Suggestions - Simple PHP code

Posted: Tue Nov 17, 2009 7:48 pm
by yamanik
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.

Re: Help Suggestions - Simple PHP code

Posted: Fri Nov 20, 2009 8:06 pm
by yamanik
Anyone please ?

Thank you.

Re: Help Suggestions - Simple PHP code

Posted: Fri Nov 20, 2009 10:15 pm
by BlaineSch
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}";
            }
        }
    }
}