note 59440 added to function.scandir
| From: | sk3391 at gmail dot com | Date: | Wed, 07 Dec 2005 02:56:04 +0000 |
| Subject: | note 59440 added to function.scandir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-99663@lists.php.net to get a copy of this message | ||
Here is a little script that i through together to count the files in my directory while excluding
the "." i hope it helps you out!
<?
$dir = ".";
$sort = 0;
$dir_open = @ opendir($dir);
while (($dir_content = readdir($dir_open)) !== false)
$files[] = $dir_content;
if ($sort == 1) {
rsort($files, SORT_STRING);
} else {
sort($files, SORT_STRING);
}
$a=0;
$b=10;
$file_s="";
while($a < $b) {
$c=1;
$d=5;
while($c < $d) {
$dot[$c.",".$a]=str_repeat(".", $c);
if($files[$a] == $dot[$c.",".$a]) {
unset($files[$a]);
} else {
}
$c++;
}
if($files[$a] != "") {
$brake[$a]="<br>";
} else {
$brake[$a]="";
}
$file_s.=$files[$a].$brake[$a];
$a++;
}
echo $file_s;
echo "<br><br><br>";
echo count($files);
?>
----
Manual Page -- http://www.php.net/manual/en/function.scandir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59440
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59440&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59440&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59440&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59440&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59440&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59440&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59440&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59440&report=yes
Search -- http://master.php.net/manage/user-notes.php