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/Bookmark

Related posts:

  1. Recursive remove directory (RMDIR) in PHP
  2. Mini gallery/slideshow with PHP and JQuery
  3. Reading mp3 informations with php (id3 tags)
  4. Validate email with smtp

Tags:

Leave a Reply