ArrayPrepend |
Description
Inserts an array element at the beginning of an array.
Returns
True, on successful completion.
Category
Array functions
Function syntax
    ArrayPrepend(array, value)
See also
ArrayAppend
Parameters
Parameter | Description
array | Name of an array
value | Value to insert at beginning of array
Example
    <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>

array |
Name of an array

value |
Value to insert at beginning of array