For the complete documentation index, see llms.txt. This page is also available as Markdown.

ArraySlice

Extracts a sub array from an existing array.

Method Signature

ArraySlice(array=[array], start=[integer], length=[integer])

Arguments

Argument
Type
Required
Description
Default

array

array

true

The array to slice.

start

integer

true

The position to start the slice from. Negative values count from the end of the array.

1

length

integer

false

The number of elements to return. 0 (default) returns all elements from start to the end of the array.

0

Examples

Simple arraySlice Example

Run Example

array = [ 
	1,
	2,
	3,
	4,
	5,
	6,
	7,
	8
];
newArray = arraySlice( array, 2, 3 );
writedump( newArray );

Result: [2,3,4]

arraySlice with no length specified

Run Example

Result: [4,5,6,7,8]

arraySlice using a negative offset

Run Example

Result: [4,5,6]

Slice an array using member function

Calling the slice member function on an array.

Run Example

Result: [2,3,4]

Additional Examples

Run Example

Last updated

Was this helpful?