All,
I have a single dimension array, populated with first name from a query. How can I make sure that there are no duplicates in the array.(retain one value and discard duplicates).
<cfset myArray = ArrayNew(1)>
<cfset myArray= #qry.FirstName#>
<cfoutput>
<cfloop from="1" to="#arraylen(myArray)#" index="i">
<cfloop from="#i+1#" to="#arraylen(myArray)#" index="j">
<cfif trim(myArray) EQ trim(myArray[j])>
#ArrayDeleteAt(myArray[j])#
</cfif>
</cfloop>
#myArray#
</cfloop>
</cfoutput>
For some reason the above code does not delete duplicates. Any help is appreciated.
Thanks
I have a single dimension array, populated with first name from a query. How can I make sure that there are no duplicates in the array.(retain one value and discard duplicates).
<cfset myArray = ArrayNew(1)>
<cfset myArray= #qry.FirstName#>
<cfoutput>
<cfloop from="1" to="#arraylen(myArray)#" index="i">
<cfloop from="#i+1#" to="#arraylen(myArray)#" index="j">
<cfif trim(myArray) EQ trim(myArray[j])>
#ArrayDeleteAt(myArray[j])#
</cfif>
</cfloop>
#myArray#
</cfloop>
</cfoutput>
For some reason the above code does not delete duplicates. Any help is appreciated.
Thanks