Utility Function: StructDeleteKeys()

A gear I often need to delete struct keys based on a list of items. Its not that I can't just loop the list and call StructDelete(), but it gets old, and this function makes it a little easier.

<cffunction name="StructDeleteKeys" returntype="void">
    <cfargument name="struct" type="struct" requried="true" />
    <cfargument name="keyList" type="string" requried="true" />
    <cfargument name="delimiters" type="string" required="false" default="," />
    <cfloop list="#arguments.keyList#" delimiters="#arguments.delimiters#" index="key">
        <cfset StructDelete(arguments.struct, key) />
    <cfreturn />

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me.

Post a job. Find one. authenticjobs.com

Interested in becoming a sponsor? Contact me.