Selecting random values from an array without repetition in ColdFusion

Well the title says it all. How to select random numbers/values from an array without using duplicate values.

<Cfset numbersArr = [1,2,3,4,5,6,7,8,9,10]>
<cfoutput>
<cfloop condition = "arraylen(numbersArr) gt 0"> 
	<cfset j = randRange(1,arraylen(numbersArr))>
	#numbersArr[j]#<br>
	<Cfset ArrayDeleteAt(numbersArr ,j)>
</cfloop>
</cfoutput>

Leave a Reply

Your email address will not be published. Required fields are marked *