That is some nasty code...
Anything that has repitition like that needs a substantial rewrite, but
I'm guessing that you know that, hence the e-mail.
I just knocked up the following function, powered by the magic of
recursion. It should be close to what you were trying to do.
function count_fil
here is what I tried but it doesn't work! any advice suggestions or
something?
$count = 0;
$dir = "/amrs";
$files1 = scandir($dir);
if ($files1 !== '.' && $files1 !== '..') {
foreach ($files1 as $files2){
$dir2 = "/amrs/$files2";
$files3 = scandir($dir2);
if ($files3 !== '.' && $files3 !== '..')
I have used these functions but how would I count them! here is my
attempt that doesn't work!:
$count = 0;
$dir = "/amrs";
$files1 = scandir($dir);
if ($files1 !== '.' && $files1 !== '..') {
foreach ($files1 as $files2){
$dir2 = "/amrs/$files2";
$files3 = scandir($dir2);
if ($files3 !== '.' && $f
ites.com
-Original Message-
From: Nicholas Couloute [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 25, 2006 9:41 PM
To: php-general@lists.php.net
Subject: [PHP] Counting files in directory and subdirectory!
I want a script where it will count all the amrs in a folder and it's sub
start here: http://www.php.net/readdir
check out as well: 'string functions' for finding 'amrs'
and loops to make recursive search...
t.
Nicholas Couloute wrote:
I want a script where it will count all the amrs in a folder and it's
sub folders like this setup:
amrs >
50 cent > amrs
ni
I want a script where it will count all the amrs in a folder and it's
sub folders like this setup:
amrs >
50 cent > amrs
nitty > amrs
bob > amrs
How would I do this?
~Nick Couloute
co-owner/Web Designer
Sidekick2Music.Com
--
PHP General Mailing List (http://www.php.net/)
I want to choose a file at random from a
directory which adheres to certain naming scheme.
I can't get it to work. It's probably something
simple...Here is a relevant snippet:
(the files are all called i??.gif and
located in a directory /images/, which is a
subdirectory of
On Wed, 13 Aug 2003 10:54:58 +0200, you wrote:
>
> I want to choose a file at random from a
> directory which adheres to certain naming scheme.
> I can't get it to work. It's probably something
> simple...Here is a relevant snippet:
>
>http://www.php.net/)
To unsubscribe, visit: http://www.p
David Otton wrote:
> On Wed, 13 Aug 2003 10:54:58 +0200, you wrote:
>
> >
> > I want to choose a file at random from a
> > directory which adheres to certain naming scheme.
> > I can't get it to work. It's probably something
> > simple...Here is a relevant snippet:
> >
> >news:pl.soc.seks.
On Friday, February 16, 2001, at 10:31 AM, Hoover, Josh wrote:
> Try this bit of code and see if it works. (I don't know if there's a less
> taxing (on the server) way to get a count of files in a directory or not.)
this code snippet won't work as a standalone. you are referencing an object
Try this bit of code and see if it works. (I don't know if there's a less
taxing (on the server) way to get a count of files in a directory or not.)
$myDirectory = dir("yourdirectory");
while($entry=$myDirectory->read())
{
$filecount++;
}
$myDirectory->close();
$number = rand(1, $filecount
I have a web page that displays an image. I would like to randomize
which image it displays when the page loads. Every possible image will
be the same dimensions and file format. Each image will be named a
consecutive number begining with 1.
The code I am using is:
$number = rand(1, 10);
$fi
12 matches
Mail list logo