note 85428 added to function.is-dir

From: Date: Fri, 29 Aug 2008 15:53:35 +0000
Subject: note 85428 added to function.is-dir
Groups: php.notes 
Request: Send a blank email to php-notes+get-143986@lists.php.net to get a copy of this message
An even better (PHP 5 only) alternative to "Davy Defaud's function": <?php function is_empty_dir($dir) { if (($files = @scandir($dir)) && count($files) <= 2) { return true; } return false; } ?> NOTE: you should obviously be checking beforehand if $dir is actually a directory, and that it is readable, as only relying on this you would assume that in both cases you have a non-empty readable directory. ---- Server IP: 209.41.74.194 Probable Submitter: 69.40.128.65 ---- Manual Page -- http://www.php.net/manual/en/function.is-dir.php Edit -- https://master.php.net/note/edit/85428 Del: integrated -- https://master.php.net/note/delete/85428/integrated Del: useless -- https://master.php.net/note/delete/85428/useless Del: bad code -- https://master.php.net/note/delete/85428/bad+code Del: spam -- https://master.php.net/note/delete/85428/spam Del: non-english -- https://master.php.net/note/delete/85428/non-english Del: in docs -- https://master.php.net/note/delete/85428/in+docs Del: other reasons-- https://master.php.net/note/delete/85428 Reject -- https://master.php.net/note/reject/85428 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#143986) next »