arrayMid

arrayMid(array, start [, count]) → returns array

Member Function Syntax

array.mid(start [, count])

This function requires Lucee. Not supported on Adobe ColdFusion.

Argument Reference for the arrayMid function

array

Required: Yes

start

Required: Yes

count

Required: No

Examples sample code invoking the arrayMid function


Using only the start parameter

Lucee 4.5+ Extract elements from an array staring with element 5 and ending with the last element of the array.

vehicles = ['Mustang','Nova','Celica','Camry','Tacoma','Tundra','Ram','F-250'];
trucks = arrayMid(vehicles, 5);
writeOutput(arrayToList(trucks));

Expected Result: Tacoma,Tundra,Ram,F-250


Using the count parameter to specify the number of elements to include

Lucee 4.5+ Extract 4 elements from an array staring with element 3.

vehicles = ['Mustang','Nova','Celica','Camry','Tacoma','Tundra','Ram','F-250'];
toyotas = arrayMid(vehicles, 3, 4);
writeOutput(arrayToList(toyotas));

Expected Result: Celica,Camry,Tacoma,Tundra


Fork me on GitHub