Skip to content

array_swap

Hyomoto edited this page Jun 13, 2021 · 2 revisions
Jump To Go Back Arguments

array_swap( array, a, b )

Returns: array

Throws: InvalidArgumentType, IndexOutOfBounds

Performs an in-place swap of the contents of the provided array. If an array is not provided, or the indexes are not integers, InvalidArgumentType will be thrown. If the indexes are outside the bounds of the array, IndexOutOfBounds will be thrown.

array_swap( ["a", "b", "c"], 0, 1 );
Output: ["b", "a", "c"]

Arguments

Name Type Purpose
array array The array to reverse
a int The first element to swap
b int The second element to swap
Clone this wiki locally