array.swap()

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

array.swap( position1=number, position2=number )

Returns: Array

Argument Description
position1
number, required

Position of first element to swap

position2
number, required

Position of second element to swap

Examples

myarray = ["one","two","three","four","five"];
res = myarray.swap(2,4);
writeDump(res);

See also