|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
skipping an array index
ok so i have 2 variables which are associated with each other: Name and UserID
i want to create an array using the UserID as the key and Name as the value. UserID doesn't necessarily start at 1, it can be like 132, 5353, and so on. I just tried populating the array with key 2521 and value "Me" users[2521] = "Me" but apparently this took forever because before Coldfusion could populate element 2521, it populated every element BEFORE 2521. So it populated 2521 ELEMENTS, which took damn near a minute. Is there a way to just populate a certain element without having to populate the elements before it? Thanks! |
|
#2
|
|||
|
|||
|
First, no, it's not possible to force CF to skip the other array elements. Second, you don't want to do this with an array. Array positions aren't meant to have "meaning", like to represent an id key. Use a structure:
<cfset myStruct = structNew() /> <cfset myStruct["2351"] = "me" /> <cfoutput>#myStruct.2351#</cfoutput> Third, if it takes your server a minute to execute these line of code: <cfset myArray = arrayNew(1) /> <cfset myArray[2351] = "me" /> Then something is wrong with your server. That took my local machine 4 milliseconds.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > skipping an array index |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|