Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Array problem


Message #1 by william.sze@s... on Wed, 22 May 2002 14:57:32 -0400
Hi,

I have two arrays with values:

Array1('AB', 'CD', 'EF')

Array2('AB', 'CD', 'GH')

How can I print out the mismatched values 'EF' and 'GH'? The array elements
are in random order.

Thanks
William

Message #2 by "Brian Lowe" <Brian.Lowe@i...> on Thu, 23 May 2002 01:08:36
How about, for each element in Array1, search through Array2 looking for a 
match - and remove it from both.

When you're done you'll have Array1('EF') and Array2('GH')

If there's a lot of elements this may take a while. It may be worth 
sorting the arrays before you begin then you'll be able to quit the search 
if you get past what you're looking for.

Brian Lowe
---------@


> I have two arrays with values:

> Array1('AB', 'CD', 'EF')
> Array2('AB', 'CD', 'GH')

> How can I print out the mismatched values 
> 'EF' and 'GH'? The array elements are in random order.

Message #3 by william.sze@s... on Thu, 23 May 2002 08:26:48 -0400
Thanks Brian, it works.



                                                                                                                   
                    "Brian Lowe"                                                                                   
                    <Brian.Lowe@i...       To:     "ASP Web HowTo" <asp_web_howto@p...>                      
                    odia.com>            cc:                                                                       
                                         Subject:     [asp_web_howto] Re: Array problem                            
                    05/22/02 09:08                                                                                 
                    PM                                                                                             
                    Please respond                                                                                 
                    to "ASP Web                                                                                    
                    HowTo"                                                                                         
                                                                                                                   
                                                                                                                   




How about, for each element in Array1, search through Array2 looking for a
match - and remove it from both.

When you're done you'll have Array1('EF') and Array2('GH')

If there's a lot of elements this may take a while. It may be worth
sorting the arrays before you begin then you'll be able to quit the search
if you get past what you're looking for.

Brian Lowe
---------@


> I have two arrays with values:

> Array1('AB', 'CD', 'EF')
> Array2('AB', 'CD', 'GH')

> How can I print out the mismatched values
> 'EF' and 'GH'? The array elements are in random order.


---

Improve your web design skills with these new books from Glasshaus.

Usable Web Menus
http://www.amazon.com/exec/obidos/ASIN/1904151027/ref=nosim/theprogramme
r-20
Constructing Accessible Web Sites
http://www.amazon.com/exec/obidos/ASIN/1904151000/ref=nosim/theprogramme
r-20
Practical JavaScript for the Usable Web
http://www.amazon.com/exec/obidos/ASIN/1904151051/ref=nosim/theprogramme
r-20





  Return to Index