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 #185735 is a reply to message #185733] Mon, 05 May 2014 14:34 Go to previous messageGo to previous message
Mr Oldies is currently offline  Mr Oldies
Messages: 241
Registered: October 2013
Karma:
Senior Member
On Mon, 05 May 2014 10:26:51 -0400, Jerry Stuckle wrote:

> On 5/5/2014 9:42 AM, richard wrote:
>> On Mon, 05 May 2014 11:11:35 +0100, Ben Bacarisse wrote:
>>
>>> richard <noreply(at)example(dot)com> writes:
>>>
>>>> On Sun, 04 May 2014 22:27:01 -0400, Jerry Stuckle wrote:
>>> <snip>
>>>> > 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] !=".") {
>>> ^ not $x
>>>
>>>> $master[$lo]=$files[$x];
>>>> $lo=$lo+1;
>>>> }
>>>> }
>>>
>>> You really need to find some what to work which lets you see all the
>>> notices and warnings that PHP can give you.
>>>
>>> By the way, writing $master[] = ... puts an element at the next unused
>>> numerical index in the array which might be what you are doing here with
>>> $lo. I'd write the above like this:
>>>
>>> foreach ($files as $file)
>>> if ($file !== '.')
>>> $master[] = $file;
>>
>> Thanks. Works like a charm.
>> Now how do I also include the ".."?
>> foreach ($files as $file)
>> if ($file !== '.' || $file!=="..")
>> $master[] = $file;
>> This does not seem to work.
>>
>> Time to implement the formidable goto eh?
>>
>
> 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 !== "..")
> ...

thank you sir that worked perfectly.
[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 03:07:52 GMT 2024

Total time taken to generate the page: 0.04262 seconds