# 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

# Arguments

| Argument | Type | Required | Description | Default |
|----------|------|----------|-------------|---------|
| array | array | Yes | Array to Swap |  |
| position1 | number | Yes | Position of first element to swap |  |
| position2 | number | Yes | Position of second element to swap |  |

# Examples

### Swap the position of two values in an array

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

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

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







# Categories

[Arrays](../../categories/array.md)

# See Also

[array.swap()](../objects/array/swap.md)