• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Name

ArraySwap

Synopsis

ArraySwap(array, position1, position2)

Swaps the values stored in the positions specified in position1 and position2. Here’s an example that takes an array and swaps the values contained in elements 5 and 2:

<cfset Grades = ArrayNew(1)>
<cfset Grades[1] = 95>
<cfset Grades[2] = 93>
<cfset Grades[3] = 87>
<cfset Grades[4] = 100>
<cfset Grades[5] = 74>
   
<b>Original Array</b><br>
<cfdump var="#Grades#">
   
<p>Swap 5th and 2nd array elements...
<cfset ArraySwap(Grades, 5, 2)>
   
<p><b>Array after ArraySwap</b><br>
<cfdump var="#Grades#">


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint