| CFML Reference
|
|
ColdFusion Functions
|
ListFirst
Description
Returns the first element of the list.
Category
List functions
Syntax
ListFirst(list [, delimiters ])
See also
ListGetAt, ListLast, ListQualify
Parameters
| Parameter |
Description |
list
|
List whose first element to retrieve
|
delimiters
|
Set of delimiters used in list
|
Usage
|
Note ColdFusion ignores empty list elements; thus, a list that is defined as "a,b,c,,,d" is treated as a four element list.
|
Example <!--- This example shows ListFirst, ListLast, and ListRest --->
<html>
<head>
<title>ListFirst Example</title>
</head>
<body>
<H3>ListFirst Example</H3>
<!--- Find a list of users who wrote messages --->
<cfquery name = "GetMessageUser" datasource = "cfsnippets">
SELECT Username, Subject, Posted
FROM Messages
</cfquery>
<cfset temp = ValueList(GetMessageUser.Username)>
<!--- Show the first user in the list --->
<P>The first user in the list is <cfoutput>#ListFirst(temp)#
</cfoutput>.
<P>The rest of the users in the list are as follows:
<cfoutput>#ListRest(temp)#</cfoutput>.
<P>The last user in the list is <cfoutput>#ListLast(temp)#</cfoutput>
</body>
</html>
|
Copyright © 2001, Macromedia Inc. All rights reserved. |
|
|