Re: Odd result from readdir()

John <[email protected]>
Newsgroups gmane.comp.php.general
Message-ID <[email protected]>
Thank you to both Yang and Peter; the problem is, as you suggested, in the line:

	while ($filename = (readdir($dh) !== false))

and it now works correctly.  I knew I was having a case of the stupids but couldn't find it.

Also, thank you Jeffery.  I was aware of scandir() and this was sort of a random choice but when it
didn't work it refocused my mind onto the question of "why not" instead of a workaround.  Surprising
how easily we can fall down the wrong rabbit hole!

Thanks again fellows for the prompt replies.

John
======
On Thu, 2024-01-18 at 10:12 +0000, Peter Ford wrote:
> I think you problem is in this line, specifically where the brackets are: 
> 
> while ($filename = (readdir($dh) !== false))
> 
> That is setting $filename to the value of the expression (readdir($dh) !== false),
> which is ’true’ or 1
> 
> I think you wanted 
> 
> while (($filename = readdir($dh)) !== false))
> 
> Cheers
> 
> Pete
> > On 18 Jan 2024, at 06:08, John <[email protected]> wrote:
> > 
> > while ($filename = (readdir($dh) !== false))
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.