note 93836 modified in function.rmdir by danbrown

From: Date: Fri, 02 Oct 2009 17:12:37 +0000
Subject: note 93836 modified in function.rmdir by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161229@lists.php.net to get a copy of this message
I had situation where the rmdir was returning warning message as within last loop it was already removed. So here is quick fix by adding is_dir to the DelTree routine below <?php function delTree($dir) { $files = glob( $dir . '*', GLOB_MARK ); foreach( $files as $file ){ if( substr( $file, -1 ) == '/' ) delTree( $file ); else unlink( $file ); } if (is_dir($dir)) rmdir( $dir ); } ?> --was-- I had situation where the rmdir was returning warning message as within last loop it was already removed. So here is quick fix by adding is_dir to the DelTree routine below function delTree($dir) { $files = glob( $dir . '*', GLOB_MARK ); foreach( $files as $file ){ if( substr( $file, -1 ) == '/' ) delTree( $file ); else unlink( $file ); } if (is_dir($dir)) rmdir( $dir ); } http://php.net/manual/en/function.rmdir.php

« previous php.notes (#161229) next »