note 54689 deleted from function.ftp-rmdir by aidan
| From: | aidan@php.net | Date: | Fri, 29 Jul 2005 07:08:28 +0000 |
| Subject: | note 54689 deleted from function.ftp-rmdir by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-92690@lists.php.net to get a copy of this message | ||
Note Submitter: rsl at zonapersonal dot com
----
Jet an other correction to the function. Since the Reg exp didn't work on my PHP I used a mix
of the proposed solutions.
function ftp_rmAll($conn_id,$dst_dir)
{
$ar_files = ftp_nlist($conn_id, $dst_dir);
arrchek($ar_files);
if (is_array($ar_files)) { // makes sure there are files
foreach ($ar_files as $st_file) { // for each file
//if ($regs=explode(' ',$st_file)) {
//arrchek($regs);
// ADDITION TO SKIP CURRENT AND PARRENT FOLDERS
if (($st_file == ".") || ($st_file == "..")) {
continue; }
if (ftp_size($conn_id, $st_file) == -1){
ftp_rmAll($conn_id, $st_file);
} else {
ftp_delete($conn_id, $st_file);
}
}
}
ftp_rmdir($conn_id, $dst_dir); // delete empty directories
}