Nov 09 2009

Is Empty Dir?

Category: PhpGiulio Pons @ 2:48 pm

Php function that return true if the directory specified is empty.


$bool = is_emptydir("./images");

function is_emptydir($which){
	$dh=dir($which);
	$emptydir=true;
	while ($file=$dh->read()) {
		if(substr($file,0,1)==".") continue;
		if(!is_dir($which."/".$file)) {
			$emptydir=false;
			break;
		}
	}
	$dh->close();
	return $emptydir;
}
Share

Tags: