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 #185729 is a reply to message #185727] Mon, 05 May 2014 13:36 Go to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma:
Senior Member
On Sun, 04 May 2014 23:07:55 -0400, richard wrote:

> On Sun, 04 May 2014 22:27:01 -0400, Jerry Stuckle wrote:

>> If written correctly a conditional for !="." would get rid of the '.'
>> entry; !=".." would get rid of the ".." entry.
>>
>> But you didn't show your entire code, so it's hard to say what could be
>> wrong.

> for ($x=0;$x<=$number;$x++){
> if ($files[x] !=".") {

As Ben pointed out, missing $ from [$x] in $files[x], but that's just
your usual broken code.

> $master[$lo]=$files[$x];
> $lo=$lo+1;
> }
> }

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(at)gmail(dot)com
[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: Sat Nov 23 17:13:03 GMT 2024

Total time taken to generate the page: 0.04058 seconds