How to insert a key value pair into a structure in ColdFusion

StructInsert() - insert a key value pair into a structure

StructInsert.cfm


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>StructInsert function example: how to insert a key value pair into a structure</title>
</head>

<body>
<h2 style="color:HotPink">StructInsert Function Example</h2>
<cfset Color=StructNew()>
<cfdump var="#Color#" label="Color">

<cfset Temp=StructInsert(Color,"ID",1,"yes")>
<cfset Temp=StructInsert(Color,"Name","Green","yes")>
<cfset Temp=StructInsert(Color,"Value","##008000","yes")>

<br />
<cfdump var="#Color#" label="Color[after insert data]">

</body>
</html>





More ColdFusion examples