Feb 12, 2002 #1 jayne1 Technical User Feb 5, 2002 7 GB Hi there! How can I set a condition that checks if a directory is empty i.e. files don't exist then take the appropriate action........pardon my ignorance!! xxx Jayne
Hi there! How can I set a condition that checks if a directory is empty i.e. files don't exist then take the appropriate action........pardon my ignorance!! xxx Jayne
Feb 12, 2002 #2 piti Technical User Apr 12, 2001 627 SK function isempty($dirname) { $handle=opendir($dirname); while ($file = readdir($handle)) { if ($file != "." && $file != ".." { return 1; //is not empty } return 0; //is empty } closedir($handle); } echo isempty("/home/users/mydir" Upvote 0 Downvote
function isempty($dirname) { $handle=opendir($dirname); while ($file = readdir($handle)) { if ($file != "." && $file != ".." { return 1; //is not empty } return 0; //is empty } closedir($handle); } echo isempty("/home/users/mydir"
Feb 12, 2002 Thread starter #3 jayne1 Technical User Feb 5, 2002 7 GB Thanks alot 'piti' your solution worked like a dream......just luv this site!! Upvote 0 Downvote