note 110489 modified in function.rmdir by danbrown

From: Date: Thu, 06 Dec 2012 14:26:22 +0000
Subject: note 110489 modified in function.rmdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-192335@lists.php.net to get a copy of this message
Glob function doesn't return the hidden files, therefore scandir can be more useful, when trying to delete recursively a tree. <?php public static function delTree($dir) { $files = array_diff(scandir($dir), array('.','..')); foreach ($files as $file) { (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); } return rmdir($dir); } ?> --was-- Glob function doesn't return the hidden files, therefore scandir can be more useful, when trying to delete recursively a tree. public static function delTree($dir) { $files = array_diff(scandir($dir), array('.','..')); foreach ($files as $file) { (is_dir("$dir/$file")) ? delTree("$dir/$file") : unlink("$dir/$file"); } return rmdir($dir); } http://php.net/manual/en/function.rmdir.php

« previous php.notes (#192335) next »