Arrayprepend - MACROMEDIA COLDFUSION MX 61-CFML Reference

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

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
array
value
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>
Description
Name of an array
Value to insert at beginning of array
ArrayPrepend
387

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents