I’m running Coldfusion8 and am struggling to access an array I have set.
My array is set like this:
Application.strConfig.respH = arrayNew(2);
Application.strConfig.respH[1][1] = "s";
Application.strConfig.respH[1][2] = 127;
Application.strConfig.respH[2][1] = "m";
Application.strConfig.respH[2][2] = 230;
...
resulting in this:
RESPH:
[array]
1) [array]
1) s
2) 127
2) [array]
1) m
2) 230
I need to get the default numbers based on a size I’m getting on a page. So for example, when I end up with m I need to get respH values for m. Right now I’m trying this:
<cfscript>
LOCAL.runner = "s,m,l,xl";
LOCAL.lt = ListGetAt(LOCAL.runner, LOCAL.i, ",");
LOCAL.height = Application.strConfig.respH[ LOCAL.lt ];
</cfscript>
Doing so, Coldfusion complains The value m cannot be converted to a number.
Question:
How do I access the elements in my strConfig object?
Thanks for helping out!
(From comments …)
If you need to look up data by a specific key, do not use arrays. Use a structure. With
arrays you must loop to find the matching key. (CF9+ supports
ArrayFind)