Help with php file lookup

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sublevel4
Forum Commoner
Posts: 33
Joined: Wed May 29, 2002 2:14 pm
Contact:

Help with php file lookup

Post by sublevel4 »

i need to write something to look in a directory and see if a file with an extension of tar.gz exists if so i need to delete it. How would i do that?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Help with php file lookup

Post by RobertGonzalez »

sublevel4
Forum Commoner
Posts: 33
Joined: Wed May 29, 2002 2:14 pm
Contact:

Re: Help with php file lookup

Post by sublevel4 »

Ok here is what i have but it doesn't work

Code: Select all

 
<?php
foreach (glob("/home/myusername/*.gz;") as $filename) {
    echo "$filename size " . filesize($filename) . "\n";
}
 
echo "filename - " . $filename;
 
?>
 
Post Reply