11-08-2009, 08:50 AM
Credits and Source: http://www.roscripts.com/
Name: Delete directory and all content
Description: This function deletes a directory with all of it's content. Second parameter is boolean to instruct the function if it should remove the directory or only the content.
Snippet:
Thankyou for reading. Be happy always
Name: Delete directory and all content
Description: This function deletes a directory with all of it's content. Second parameter is boolean to instruct the function if it should remove the directory or only the content.
Snippet:
PHP Code:
function rmdir_r ( $dir, $DeleteMe = TRUE )
{
if ( ! $dh = @opendir ( $dir ) ) return;
while ( false !== ( $obj = readdir ( $dh ) ) )
{
if ( $obj == '.' || $obj == '..') continue;
if ( ! @unlink ( $dir . '/' . $obj ) ) rmdir_r ( $dir . '/' . $obj, true );
}
closedir ( $dh );
if ( $DeleteMe )
{
@rmdir ( $dir );
}
}
Thankyou for reading. Be happy always