function move_d($source,$target){ $dest_name=basename($source); if(is_dir($source)){ if(!mkdir($target.$dest_name)){ return false; } $d=dir($source); while(($entry=$d->read())!==false){ if(is_dir($source.$entry)){ if($entry=="."||$entry==".."){ continue; }else{ move_d("$source$entry/","$target$dest_name/"); } }else{ if(!copy("$source$entry","$target$dest_name/$entry")){ return false; } } } }else{ if(!copy("$source$entry","$target$dest_name/")){ return false; } } return true; }