Code to delete files of a folder

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
parwez
Forum Newbie
Posts: 1
Joined: Fri Feb 01, 2008 4:21 am

Code to delete files of a folder

Post by parwez »

$dir="./";
$fd = @opendir($dir);
while (($part = @readdir($fd)) == true) {
if (!is_dir($part) && ($part != "." && $part != "..")) {
$file_array[]=$part;
}
}
$cntPage=count($file_array);
for($p=0;$p<$cntPage;$p++)
{
$PageName= $file_array[$p];
unlink($PageName);
}
Post Reply