ArrayResize

Resets an array to a specified minimum number of elements. ArrayResize can provide some performance gains if used to size an array to its expected maximum. Use ArrayResize immediately after creating an array with ArrayNew for arrays greater than 500 elements.

Note that ColdFusion arrays expand dynamically as data is added.

Returns a Boolean TRUE on successful completion.

Syntax

ArrayResize(array, minimum_size)
array

Name of the array you want to resize.

minimum_size

Minimum size of the specified array.

Example

<!--- This example shows the use of ArrayResize --->
<HTML>
<HEAD>
<TITLE>ArrayResize Example</TITLE>
</HEAD>

<BODY>
<H3>ArrayResize Example</H3>

<!--- perform a query to get the list of course --->
<CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
SELECT * FROM Courses
</CFQUERY>
<!--- make a new array --->
<CFSET MyArray = ArrayNew(1)>
<!--- resize that array to the number of records
in the query --->
<CFSET temp = ArrayResize(MyArray, GetCourses.RecordCount)>
<CFOUTPUT>
The array is now #ArrayLen(MyArray)# elements, to match
the query of #GetCourses.RecordCount# records.
</CFOUTPUT>

</BODY>
</HTML>       

1