note 71328 added to function.unlink

From: Date: Wed, 22 Nov 2006 20:27:36 +0000
Subject: note 71328 added to function.unlink
Groups: php.notes 
Request: Send a blank email to php-notes+get-119987@lists.php.net to get a copy of this message
Here is simple function that will find and remove all files (except "." ones) that match the expression ($match, "*" as wildcard) under starting directory ($path) and all other directories under it. function rfr($path,$match){ static $deld = 0, $dsize = 0; $dirs = glob($path."*"); $files = glob($path.$match); foreach($files as $file){ if(is_file($file)){ $dsize += filesize($file); unlink($file); $deld++; } } foreach($dirs as $dir){ if(is_dir($dir)){ $dir = basename($dir) . "/"; rfr($path.$dir,$match); } } return "$deld files deleted with a total size of $dsize bytes"; } ---- Server IP: 66.163.161.117 Probable Submitter: 87.116.164.92 ---- Manual Page -- http://www.php.net/manual/en/function.unlink.php Edit -- https://master.php.net/note/edit/71328 Del: integrated -- https://master.php.net/note/delete/71328/integrated Del: useless -- https://master.php.net/note/delete/71328/useless Del: bad code -- https://master.php.net/note/delete/71328/bad+code Del: spam -- https://master.php.net/note/delete/71328/spam Del: non-english -- https://master.php.net/note/delete/71328/non-english Del: in docs -- https://master.php.net/note/delete/71328/in+docs Del: other reasons-- https://master.php.net/note/delete/71328 Reject -- https://master.php.net/note/reject/71328 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#119987) next »