How to check whether a specific key is present in a structure in ColdFusion

StructKeyExists() - check whether a specific key is present in a structure

StructKeyExists.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>StructKeyExists function example: how to check whether a specific key is present in a structure</title>
</head>

<body>
<h2 style="color:HotPink">StructKeyExists Function Example</h2>

<cfset Color=StructNew()>
<cfset Color.ID=1>
<cfset Color.Name="LightCyan">
<cfset Color.Value="##E0FFFF">
<cfdump var="#Color#" label="Color">

<br />
<cfoutput>
<b>
Color Structure Key Exists[Name]?: #StructkeyExists(Color,"Name")#
<br />
Color Structure Key Exists[Names]?: #StructkeyExists(Color,"Names")#
</b>
</cfoutput>
</body>
</html>






More ColdFusion examples