ArraySwap

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

Returns: boolean

Usage

ArraySwap( array, position1, position2 )

Arguments

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