ArrayPrepend

Inserts an array element at the beginning of an array.

True, on successful completion.

Array functions

ArrayPrepend(array, value)

ArrayAppend

Parameter Description

array

Name of an array

value

Value to insert at beginning of array

<h3>ArrayPrepend Example</h3>
<cfquery name = "GetEmployeeNames" datasource = "cfsnippets">
   SELECT FirstName, LastName FROM Employees
</cfquery>
<!--- create an array --->
<cfset myArray = ArrayNew(1)>
<!--- set element one to show where we are --->
<cfset myArray[1] = "Test Value">
<!--- loop through query. Append names successively before last element (list
reverses itself from the standard queried output, as it keeps
prepending the array entry) ---> <cfloop query = "GetEmployeeNames"> <cfoutput>#ArrayPrepend(myArray, "#FirstName# #LastName#")# </cfoutput>, Array was prepended<br> </cfloop> <!--- show the resulting array as a list ---> <cfset myList = ArrayToList(myArray, ",")> <!--- output the array as a list ---> <cfoutput> <p>The contents of the array are as follows: <p>#myList# </cfoutput>

View comments on LiveDocs