note 42725 added to function.unlink

From: Date: Thu, 27 May 2004 09:14:04 +0000
Subject: note 42725 added to function.unlink
Groups: php.notes 
Request: Send a blank email to php-notes+get-70166@lists.php.net to get a copy of this message
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); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.unlink.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+42725 Delete -- http://master.php.net/manage/user-notes.php?action=delete+42725&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+42725&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#70166) next »