How to get the first element of a List in ColdFusion

ListFirst() - get the first element of a List

ListFirst.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ListFirst function example: how to get the first element of a List</title>
</head>

<body>
<h2 style="color:hotpink">ListFirst Function Example</h2>

<cfset ColorList="DimGray,DodgerBlue,FireBrick">
<cfoutput><b>ColorList: #ColorList#</b></cfoutput>

<br /><br />
<cfoutput><b>ColorList First Element: #ListFirst(ColorList,",")#</b></cfoutput>
</body>
</html>






More ColdFusion examples