# how to join two arrays? - Page 2

•  Subject
• Author
• Posted on

## Re: solved

On 5/5/2014 9:42 AM, richard wrote:

You're close.  You want to add it if \$file != "." AND \$file != "..".

If \$file equals ".", it cannot equal "..", and vice versa.  So the test
you have is always true.

So what you want is

if (\$file !== "." && \$file !== "..")
...

--
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

## Re: solved

On Mon, 05 May 2014 10:26:51 -0400, Jerry Stuckle wrote:

thank you sir that worked perfectly.

## Re: solved

40tude.net:

[...]

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,

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 ||.

## Re: solved

On Sun, 04 May 2014 23:07:55 -0400, richard wrote:

As Ben pointed out, missing \$ from [\$x] in \$files[x], but that's just

for ( \$x=0; \$x <= \$number; \$x++ )
if ( \$files[\$x] != "." && \$files[\$x] != ".." )
\$master[\$lo++] = \$files[\$x];

The line:

\$master[\$lo++] = \$files[\$x];

does the following:

First it assigns the value of \$files[\$x] to \$master[\$lo]
Then it increments \$lo by 1

And as Ben pointed out, it's possible that the following will work too:

for ( \$x=0; \$x <= \$number; \$x++ )
if ( \$files[\$x] != "." && \$files[\$x] != ".." )
\$master[] = \$files[\$x];

As it just increments the numeric index of \$master by 1 each time it
assigns another element.

--
Denis McMahon, denismfmcmahon@gmail.com