christa Posted November 23, 2009 Share Posted November 23, 2009 hi, i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder. I must to delete only the folders in array, i use this code: $all_folders = array(); while ($row = mysql_fetch_array($result)) { $all_folders[] = $row['folder_id']; } function removedirfiles($all_folders){ $open=readdir($all_folders); while($files=readdir($open)){ unlink("$all_folders/$files"); } rmdir($all_folders); } removedirfiles("$all_folders"); but it returns those errors: readdir(): supplied argument is not a valid Directory resource rmdir(Array) [function.rmdir]: No such file or directory Link to comment https://forums.phpfreaks.com/topic/182643-remove-directories-not-empty/ Share on other sites More sharing options...
christa Posted November 23, 2009 Author Share Posted November 23, 2009 hi, i have an array that contains some names (1,4,6,56...). Every integer is a name of a folder. I must to delete only the folders not in array, i use this code: $all_folders = array(); while ($row = mysql_fetch_array($result)) { $all_folders[] = $row['folder_id']; } function removedirfiles($all_folders){ $open=readdir($all_folders); while($files=readdir($open)){ unlink("$all_folders/$files"); } rmdir($all_folders); } removedirfiles("$all_folders"); but it returns those errors: readdir(): supplied argument is not a valid Directory resource rmdir(Array) [function.rmdir]: No such file or directory Link to comment https://forums.phpfreaks.com/topic/182643-remove-directories-not-empty/#findComment-963962 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.