just add a line to check for an empty string in $file and break the loop
after printing the message you want to print.
i.e.
$continue = true; /* Set a BOOLEAN variable to keep the loop going as
long as there are files */
if ($handle = opendir('./ssgi/')) {
while (false !== ($file =
Subject: Re: [wdvltalk] PHP: determine if a directory is empty
just add a line to check for an empty string in $file and
break the loop
after printing the message you want to print.
i.e.
$continue = true; /* Set a BOOLEAN variable to keep the
loop going as long
How about this?
$empty_dir = true;
if ($handle = opendir('./ssgi/')) {
while (false !== ($file = readdir($handle))) {
if ($file != . $file != ..) {
echo a href=\ssgi/$file\$file/abr /\n;
$empty_dir = false;
}
}
closedir($handle);
}
if ($empty_dir) {
echo
:[EMAIL PROTECTED]
Sent: Thursday, June 09, 2005 11:01 AM
To: wdvltalk@lists.wdvl.com
Subject: Re: [wdvltalk] PHP: determine if a directory is empty
just add a line to check for an empty string in $file and
break the loop
after printing the message you want to print.
i.e.
$continue = true
Sheila Fenelon wrote:
How about this?
$empty_dir = true;
if ($handle = opendir('./ssgi/')) {
while (false !== ($file = readdir($handle))) {
if ($file != . $file != ..) {
echo a href=\ssgi/$file\$file/abr /\n;
$empty_dir = false;
}
}
Hi -
My idea of sending to a file and counting the lines is essentially the same
as several other suggestions:
1) Charles King suggested outputting to a array and then checking the
contents of the array, and
2) Pat Richards suggested adding a counter, which would have exactly the
same effect
Without actually trying it, the first thing that comes to mind is to
insert a counter in your while loop. If, at the conclusion of the loop,
it only == 2, then you're likely in an empty directory (you'd have the .
And .. To give you the two).
Make sense?
-Original Message-
From:
Pat Richard wrote:
Without actually trying it, the first thing that comes to mind is to
insert a counter in your while loop. If, at the conclusion of the loop,
it only == 2, then you're likely in an empty directory (you'd have the .
And .. To give you the two).
Make sense?
Something I nabbed
Hi Perry -
If you write the output to a file, instead of to the screen, then you can
simply test the number of lines in the ASCII file to see if there is a line
for a file, and based on that return either the report you have in the file
or your text string.
Hope I'm clear on this. This is how I