Gets the first element of a list.
The first element of a list. If the list is empty, returns an empty string.
ListFirst(list [, delimiters ])
ListGetAt,
ListLast,
ListQualify
ColdFusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements.
<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)> <p>Before editing the list, it is: <cfoutput>#ValueList(GetMessageUser.Username)#</cfoutput>. <p>(Users who posted more than once are listed more than once.) <!--- Show the first user in the list ---> <p>The first user in the list is: <cfoutput>#ListFirst(temp)#</cfoutput> <p>The rest of the list is: <cfoutput>#ListRest(temp)#</cfoutput>. <p>(Users who posted more than once are listed more than once.) <p>The last user in the list is: <cfoutput>#ListLast(temp)#</cfoutput>