Array

Unlike some other languages, Arrays in CFML start at 1 rather than 0.

Arrays in Lucee are passed by reference, see Migrating to Lucee from Coldfusion

array.append() Appends an array element to an array.
array.avg() Calculates the average of the values in an array. All elements in the array must contain values that can be automatically converted to numeric.
array.clear() Removes all elements from an array.
array.contains() Returns the position of the first element in the array that matches the item that we are searching for, or 0 if the item is not found.
array.containsNoCase() Returns the position of the first element in the array whose string value contains the substring passed (not case sensitive), or 0 if no such element is found.
array.delete() Deletes specified object from given array
array.deleteAt() Deletes an element from an array and resizes the array so that the deleted element doesn't leave a gap.
array.deleteNoCase() Deletes specified object from given array, in case of a string the case of the string does not matter.
array.each() call the given UDF/Closure with every value in the array.
array.every() This function calls a given closure/function with every element in a given array and returns true, if all of the closure calls returns true.
array.filter() This function creates a new Array that returns all the values from an array that match the given filter.
array.find() These functions searches the array for the specified object.
array.findAll() These functions searches the array for the specified object and return the positions of all occurrence of this values.
array.findAllNoCase() These functions searches the array for the specified object and return the positions of all occurrence of this values.
array.findNoCase() These functions performs a case-insensitive search in the array for the specified object.
array.first() Returns the first item from an array. Throws an error if the array is empty.
array.indexExists() Returns whether there exists an item in the array at the selected index.
array.insertAt() Inserts a value at the specified position in the array. If the element is inserted before the end of the array, Lucee shifts the positions of all elements with a higher index to make room.
array.isDefined() Returns whether there exists an item in the array at the selected index.
array.isEmpty() Determines if the array is empty.
array.last() Returns the last element of an array
array.len() Returns the length of a given array
array.map() Calls the given closure with every element in the given array. the function returns a array that contains all values returned by the closure.
array.max() Returns the largest numeric value in an array. If the array parameter value is an empty array, returns zero. All elements must contain values that can be automatically converted to numeric values.
array.median() Calculates the Median value of items in an array. All elements in the array must contain values that can be converted to numeric.
array.merge() This function creates a new array with data from the two passed arrays. To add all the data from one array into another without creating a new array see the built in function ArrayAppend(arr1, arr2, true).
array.mid() Extracts a sub array from a array.
array.min() Returns the smallest numeric value in an array. If the array parameter value is an empty array, returns zero. All elements must contain values that can be automatically converted to numeric values.
array.prepend() Inserts an array element at the beginning of an array and shifts the positions of the existing elements to make room.
array.reduce() Iterates over every entry of the given array and calls the closure with every element. This function will reduce the array to a single value and will return the value.
array.resize() Resets an array to a specified minimum number of elements. This can improve performance, if used to size an array to its expected maximum. For more than 500 elements, use ArrayResize immediately after using the ArrayNew tag.
array.reverse() Returns a new array, with all the elements reversed
array.set() In a one-dimensional array, sets the elements in a specified index range to a value. Useful for initializing an array after a call to ArrayNew.
array.slice() Returns a new array, from the start position up to the count of elements
array.some() This function calls a given closure/function with every element in a given array and returns true, if one of the closure calls returns true.
array.sort() Sorts array elements numerically or alphanumerically.
array.sum() The sum of values in an array. If the array parameter value is an empty array, returns zero.
array.swap() Swaps array values of an array at specified positions. This function is more efficient than multiple cfset tags
array.toList() Transform the array to a list of elements delimiter by the given string
array.toStruct() Transform the array to a struct, the index of the array is the key of the struct

See also