#19772 [Opn->Csd]: feature request count_files() and count_directories()

From: Date: Mon, 07 Oct 2002 17:12:23 +0000
Subject: #19772 [Opn->Csd]: feature request count_files() and count_directories()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-21724@lists.php.net to get a copy of this message
 ID:               19772
 Updated by:       sniper@php.net
 Reported By:      psyk_x@hotmail.com
-Status:           Open
+Status:           Closed
 Bug Type:         Feature/Change Request
 Operating System: Windows XP Home
 PHP Version:      4.2.3
 New Comment:

This is what can be used for this:

http://www.php.net/manual/en/function.glob.php

No special functions for just counting files/dirs are not needed.




Previous Comments:
------------------------------------------------------------------------

[2002-10-05 18:52:12] psyk_x@hotmail.com

That's an idea but I already used readdir :)
I didn't think I could use it for directories, though...

It's just that since I don't use mysql, I use it often to count stuff
in my databases (e.g.: My news database outputs the number of news and
the number of news = the number of files in the directory) and it makes
scripts  more complicated. I always have to copy the same code
everywhere because I can't remember it.

Thanks,
PsykX

------------------------------------------------------------------------

[2002-10-05 17:49:26] nicos@php.net

Well, you should do that with readdir() with incrementing a variable.

------------------------------------------------------------------------

[2002-10-05 15:45:37] psyk_x@hotmail.com

I think it would be handy to have these 2 functions. The difference is
that one would count files and the other counts directories, like you
probably guessed it.

For example, if you d'like to count files ending with php3 and
directories, you would do this :

---
//Opens a directory and counts files and folders in it
$dir = opendir(string path);
 $files = count_files($dir, "php3");
 $directories = count_directories($dir);
closedir($dir);

//Outputs the number of files and directories
echo $files;
echo "<br>";
echo $directories;
---

If you d'like to count every files you would put nothing in the
extension parameter

I know there's a way to count files and directories but it would be a
"shortcut" function.


Thanks,

PsykX
(Sorry for my english...)

------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=19772&edit=1



Thread (7 messages)

« previous php.bugs (#21724) next »