You are here: Re: deleting all the files in a directory « PHP Programming Language « IT news, forums, messages
Re: deleting all the files in a directory

Posted by Andy Hassall on 02/13/06 23:14

On 13 Feb 2006 12:14:40 -0800, laredotornado@zipmail.com wrote:

>Using PHP 4, what are the shortest amount of lines I can write to
>delete all the files in a given directory?

$dir = '/x/y/z';
if ($dir = opendir($dir))
{
while (($file = readdir($dir)) !== false)
{
if (is_file("$dir/$file"))
{
unlink("$dir/$file");
}
}
}

If you really want it shorter you can remove some of the braces.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация