FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » how to join two arrays?
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: solved [message #185751 is a reply to message #185730] Tue, 06 May 2014 00:55 Go to previous messageGo to previous message
Doug Miller is currently offline  Doug Miller
Messages: 171
Registered: August 2011
Karma:
Senior Member
richard <noreply(at)example(dot)com> wrote in news:1u66bqszrlp57$.2ce1bbokt163.dlg@
40tude.net:

[...]
> if ($file !== '.' || $file!=="..")
> $master[] = $file;
> This does not seem to work.

Depends on your definition of "work", I suppose. It definitely does work, in the sense that it
certainly is doing what you told it to. I'm pretty sure it's not doing what you expected it to do,
but that's because your expectations don't match your code.

Consider what happens when $file is equal to "." The first part of your compound condition
is FALSE. The second part is TRUE.

FALSE || TRUE is TRUE.

Now what happens when $file is equal to "..". The first part is TRUE, and the second part is
FALSE.

TRUE || FALSE is TRUE.

Finally, if $file is equal to, say, "abc". Now both parts of the condition are TRUE.

TRUE || TRUE is TRUE.

The results you *want* are FALSE, FALSE, TRUE respectively -- that is, you want the result
to be FALSE when *either* of its inputs is FALSE, and TRUE only if *both* of its inputs are
TRUE. That describes &&, not ||.

>
> Time to implement the formidable goto eh?

No, it's time to fix your broken logic. Google "De Morgan's Laws" for more information.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: count() problem
Next Topic: part two same issue - unwanted empty values in array
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 21:52:59 GMT 2024

Total time taken to generate the page: 0.04938 seconds