Swaps array values of an array at specified positions. ArraySwap
can be used with greater efficiency than multiple cfset tags.
Returns a Boolean TRUE on successful completion.
ArraySwap(array, position1, position2)
Parameter |
Description |
---|---|
array |
Name of an array whose elements to swap |
position1 |
Position of first element to swap |
position2 |
Position of second element to swap |
<!--- This example shows ArraySwap ---> <html> <head> <title>ArraySwap Example</title> </head> <body> <H3>ArraySwap Example</H3> <cfset month = ArrayNew(1)> <cfset month[1] = "February"> <cfset month[2] = "January"> <cfset temp = ArraySwap(month, 1, 2)> <cfset temp = ArrayToList(month)> <P>Show the results: <cfoutput>#temp#</cfoutput> </body> </html>