How do you return the value of a dynamic structure key?
If you need to return the value of a structure key where the key is dynamic, you must use bracket notation. Assume myStruct is a structure and you want to get the value of the key stored in a variable, keyname.
<cfset value = myStruct[keyname]>
If the value of mystruct.foo was "Jacob", the variable value will be "Jacob."
Bracket notation should also be used when key names have a space or other invalid character. If myStruct have a key called "Raymond Camden", you would not be able to do this:
Instead, bracket notation must be used:
This question was written by Ben Forta.
It was last updated on January 25, 2006 at 2:03:11 PM EST.
CFML Referenced
Categories
Comments
There are no comments for this entry.