note 42725 deleted from function.unlink by tomsommer

From: Date: Thu, 27 May 2004 09:25:19 +0000
Subject: note 42725 deleted from function.unlink by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-70168@lists.php.net to get a copy of this message
Note Submitter: relsqui@armory.com ---- Here's a simple function to clean out a directory (only tested on a Linux box thus far... I think you have to reverse the slash or something under Windows). <?php $exfiles=scandir($exdir); foreach($exfiles as $exfile){ unlink($exdir . "/" . $exfile); } ?> If you don't have PHP 5 and therefore no scandir(), you can do this instead: <?php $exfiles=explode("\n", trim(shell_exec("ls " . $exdir))); foreach($exfiles as $exfile){ unlink($exdir . "/" . $exfile); } ?>

« previous php.notes (#70168) next »