array_resize

With this function you can resize an existing array dimension to be a new size. You supply the array to be resized as well as the new number of indices for the array, and the function will resize that array. Note that this function is designed for resizing an array down to a smaller length as you can resize up by simply setting a new index in the array. That said, if you do use it to size up an array, then any new indices will be set to the default value of 0.

This function can also be used for multi-dimension arrays, as long as you specify which dimension you want to resize when you supply the array index, following this pattern:

// Resize the first dimension of the array
array_resize(my_array, 10);

// Resize the second dimension of the array
array_resize(my_array[0], 10);

// Resize the third dimension of the array
array_resize(my_array[0][0], 10);

// etc...

 

Syntax:

array_resize(array_index, new_size);

Argument Description
array_index The index of the array to resize.
new_size The new size for the array (an integer, starting from 0).

 

Returns:

N/A

 

Example:

if array_length(a) > 10
    {
    array_resize(a, 10);
    }

The above code checks the length of an array and if it has more than 10 indices then it is resized.