Skip to main content

The "array_fill" Function

Syntax#

array_fill(id, [value]);
ArgumentTypeDescription
idarrayThe index of a previously-created array to modify
[value]anyOptional: Sets a value to assign to all new cells (default 0)

Description#

Finds the longest dimension of a multidimensional array and fills all other dimensions to match the same length, optionally assigning a default value to any new cells created. If a custom value is not specified, 0 will be used by default.

Can be useful for parsing arrays where the parser must assume a certain size for all dimensions of an array. However, note that this function fills array length only. Sub-dimensions can still be non-uniform in depth, which cannot be solved by this function, as doing so would result in data loss.

Example#

array_fill(my_array);
array_fill(my_array, -1);