ArraySwap() - swap array values of an array at specified positions
ArraySwap.cfm
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ArraySwap function example: how to swap array values of an array at specified positions</title>
</head>
<body>
<h2 style="color:Green">ArraySwap Function Example</h2>
<cfset ColorArray = ArrayNew(1)>
<cfset ArrayAppend(ColorArray,"Red")>
<cfset ArrayAppend(ColorArray,"Green")>
<cfset ArrayAppend(ColorArray,"Blue")>
<cfdump var="#ColorArray#" label="ColorArray">
<br />
<cfset Temp = ArraySwap(ColorArray,1,3)>
<cfdump var="#ColorArray#" label="ColorArray[After Swap Position 1,3]">
</body>
</html>
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjaPgpr1s96ID0JigosT1BSjS1FijBlqiFz3FzeKuKaRkU7TXKY3HMgiifLtSd5mKeaJZ5r7FfzzD0sAScZymtHR7Eo7dC7X2LlAaCdaNzzF4mPgW8zEhSxuN1-BKWjQ0xXat0mG0tpjZQ/s1600/ArraySwap.gif)