User Guide

698 Chapter 3: ColdFusion Functions
StructDelete
Description
Removes an element from a structure.
Returns
Boolean value. The value depends on the indicatenotexisting parameter value.
Category
Structure functions
Function syntax
StructDelete(structure, key [, indicatenotexisting ])
See also
Structure functions
History
ColdFusion MX: Changed behavior: this function can be used on XML objects.
Parameters
Example
<h3>StructDelete Function</h3>
<!--- Delete the surrounding comments to make this page work
<p>This example uses the StructInsert and StructDelete functions.
<!--- Establish params for first time through --->
<cfparam name = "firstname" default = "Mary">
<cfparam name = "lastname" default = "Sante">
<cfparam name = "email" default = "msante@allaire.com">
<cfparam name = "phone" default = "777-777-7777">
<cfparam name = "department" default = "Documentation">
<cfif IsDefined("FORM.Delete")>
<cfoutput>
Field to be deleted: #form.field#
</cfoutput>
<p>
<CFScript>
employee = StructNew();
StructInsert(employee, "firstname", firstname);
StructInsert(employee, "lastname", lastname);
StructInsert(employee, "email", email);
StructInsert(employee, "phone", phone);
StructInsert(employee, "department", department);
</CFScript>
Before deletion, employee structure looks like this:
<cfdump var="#employee#">
<br>
Parameter Description
structure Structure or a variable that contains one. Contains element to remove
key Element to remove
indicatenotexisting True: return Yes if key exists; No if it does not.
False: return Yes regardless of whether key exists. Default.