Inserts an array element at the beginning of an array.
True, on successful completion.
ArrayPrepend(array, value)
| 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>
ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 6
Comments are no longer accepted for ColdFusion MX. ColdFusion 8 is the current version.
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt114.htm