Description
Returns part of an array with only the elements you need.
Returns
Portion of an array based on the offset and length settings.
History
ColdFusion 10: Added this function.
Syntax
arraySlice(array,offset,length)
Properties
Parameter |
Description |
---|---|
array |
Name of the array that you want to slice. |
offset |
Specifies the position from which to slice the array. Negative value indicates that the array is sliced, with sequence starting from array's end. |
length |
Element count from offset. |
Example
<cfscript> array = [1, 2, 3, 4, 5, 6, 7, 8]; newArray = arraySlice(array, 2, 3);//returns 2,3,4 newArray = arraySlice(array, 4);//returns 4,5,6, 7, 8 newArray = arraySlice(array, -5, 3);//returns 4,5,6 </cfscript> |