Contact Us

 Bharat Patel     Feb,08 2017

Remove duplicate elements from the list using coldfusion

Hi All,

List’s function is very useful in ColdFusion technology. We often use lists in our code but sometime we find duplicate elements in the list and we need to remove it. Here is the simple function to remove duplicate elements from list. Have a look at below code I hope it will helpful for you.

	<cfscript>
	function removeDuplicateFromList(lst,delim){
	var Lst2 = '';
	for(i=1;i<=ListLen(lst);i++){
	value = ListGetAt(lst,i);
	if(not ListFindNoCase(Lst2,value)){
	Lst2 = ListAppend(Lst2,value,delim);
	}
	}
	return Lst2;
	}
	</cfscript>