Help Suggestions - Simple PHP code

Looking for volunteers to join your project? Need help with a script but can't afford to pay? Want to offer your services as a volunteer to build up your portfolio? This is the place for you...

Moderator: General Moderators

Post Reply
yamanik
Forum Newbie
Posts: 2
Joined: Tue Nov 17, 2009 7:29 pm

Help Suggestions - Simple PHP code

Post 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.
yamanik
Forum Newbie
Posts: 2
Joined: Tue Nov 17, 2009 7:29 pm

Re: Help Suggestions - Simple PHP code

Post by yamanik »

Anyone please ?

Thank you.
User avatar
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

Post 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}";
            }
        }
    }
}
 
Post Reply