Re: Odd result from readdir()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <john.iliffe@xxxxxxxxx> wrote:
> > 
> > while ($filename = (readdir($dh) !== false))
> 




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux