|
-
Aug 19th, 2002, 08:02 AM
#1
Thread Starter
Fanatic Member
Count the each element in an array
I have an array and when I display the array, it looks like this:
Group1
Dave
John
Dave
Mike
Mike
Leo
Amos
Brian
Dave
I want to have it displayed like this:
Group1
Dave 3
John 1
Mike 2
Leo 1
Amos 1
Brian 1
Here is my code at the moment to display as in the first example:
<u>Group1</u><br>
<%for i=1 to Var10%>
<%=Var10P(i)%><br>
<%next%>
-
Aug 19th, 2002, 09:45 AM
#2
Fanatic Member
Can you use a database?
Insert the values of the array into a table and then do a GroupBy query to count the number of occurences of each name.
Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment. 
-
Aug 19th, 2002, 09:46 AM
#3
Thread Starter
Fanatic Member
I prefer not to use a database...
-
Aug 19th, 2002, 09:50 AM
#4
PowerPoster
Well
You could do it with two arrays...
Loop eveyname in your primary array.
Create/update an array with the counts of names...
Sya "BOB" is the current arry entry. Loop thru the second arry trying to find "BOB". If it's not in there, add the name with COUNT of 1, if it is in there, add to the count.
Note : If alot of names, this will be slow. Suggest using database, too.
Remaining quiet down here !!!
BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|