Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Delete directory and all content
#1
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:

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 '/' $objtrue );
    }
    
    
closedir $dh );
    if ( 
$DeleteMe )
    {
        @
rmdir $dir );
    }



Thankyou for reading. Be happy always Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  please delete Spagnum 0 789 06-14-2012, 12:28 AM
Last Post: Spagnum
  Delete email forwarder? eXe 0 637 05-26-2010, 02:13 AM
Last Post: eXe
  Directory Contents zone 0 527 11-07-2009, 03:38 AM
Last Post: zone
  Directory Contents zone 0 517 11-06-2009, 07:12 AM
Last Post: zone
  Count the Number of Files in a Directory zone 0 558 11-06-2009, 06:44 AM
Last Post: zone

Forum Jump:


Users browsing this thread: 1 Guest(s)