I have the following array with a structure within each array (see this jsfiddle for what the array looks like).
How do I loop over the array, then get the structure within the array to pull out the userid? I keep getting errors with variations that I’ve tried. The most common error I’m getting is:
Must be a valid structure or COM object
Here is the code I have to loop over the array and structure that is generating the error above (see this jsfiddle for what the array looks like).
<cfloop from="1" to="#ArrayLen(getTeamDetails)#" index="s">
#s#) #getTeamDetails[s][uid]#<br>
</cfloop>
Mark asked for some more code so I’ve included how I’m populating the array/structure:
<cfoutput query="getTeam">
<cfset getTeamDetails[getTeam.currentrow] = StructNew()>
<cfset a = StructInsert(getTeamDetails[getTeam.currentrow], "firstname", getTeam.firstname, 1)>
<cfset a = StructInsert(getTeamDetails[getTeam.currentrow], "lastname", getTeam.lastname, 1)>
<cfset a = StructInsert(getTeamDetails[getTeam.currentrow], "uid", getTeam.uid, 1)>
</cfoutput>
I think this should work:
I created your array and structure from scratch and loop through it to access the structkey you need to access.