note 40496 deleted from function.unlink by tomsommer

From: Date: Sat, 06 Mar 2004 23:01:24 +0000
Subject: note 40496 deleted from function.unlink by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-66366@lists.php.net to get a copy of this message
Note Submitter: diwi@seznam.cz ---- And what about this function for deleting files with using * and ? <?php function delete($dir, $pattern) { $pattern = str_replace(array("\*","\?"), array(".*","."), preg_quote($pattern)); if (substr($dir,-1) != "/") $dir .= "/"; if (is_dir($dir)) { $d = opendir($dir); while ($file = readdir($d)) { if (is_file($dir.$file) && ereg("^".$pattern."$", $file)) { unlink($dir.$file); } } closedir($d); return 1; } else return 0; } ?>

« previous php.notes (#66366) next »