ArraySwap()

Swaps array values of an array at specified positions. This function is more efficient than multiple cfset tags

ArraySwap( array=array, position1=number, position2=number );

Returns: Boolean

Argument Description
array
array, required

Array to Swap

position1
number, required

Position of first element to swap

position2
number, required

Position of second element to swap

Examples

Swap the position of two values in an array

superiorArray = ['Spider-Man','Green Goblin','Doctor Octopus','Venom'];

arraySwap(superiorArray,1,3); dump(superiorArray);

// member function superiorArray.swap(1,3); dump(superiorArray);

See also