Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Arrays 1

Status
Not open for further replies.

iao

Programmer
Feb 23, 2001
111
US
Is there a way to delete duplicate values in an array or a list?

For example, if list has values of:

1,2,3,4,3,5,6,7

and I only want 1,2,3,4,5,6,7 to be in the list (or the array), I need to somehow remove the other '3'. Is there an easy way to do so?
 
Here's on way:

<CFSCRIPT>
aMyArray = ListToArray(&quot;1,2,3,4,3,5,6,7&quot;);

lTmp = &quot;&quot;;
for(i=1; i LT ArrayLen(aMyArray); i=i+1)
if( NOT ListFindNoCase(lTmp, aMyArray
Code:
[
i
Code:
]
) )
lTmp = ListAppend(lTmp, aMyArray
Code:
[
i
Code:
]
);

aMyArray = ListToArray(lTmp);

</CFSCRIPT> - tleish
 
Wow, that worked like a charm. I would have never figured that one out on my own. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top