|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Whats difference between structure and array?
What's difference between structure and array?
I'm trying to do a who's online list on an online community, but i'm a bit confused. Should i create a structure of those that went through the login form and then loop it to see if the guys in the list? do i do this with structure or array and what's the difference? ![]() |
|
#2
|
|||
|
|||
|
The crucial difference is that structure elements are referenced by key name, where arrays are referenced numerically. Also, in a structure the order is essentially random, while an array enforces the order of the elements.
So, if you have a set of data that you want to reference by key and you are not concerned with the order of the elements (ie user.firstName, user.lastName) use a structure. If you have a set of data where you don't know how many elements will be in it, or where the order of the elements is important, use an array (onlineUsers[1], onlineUsers[2], etc.) The "who's online" data set that you describe should be stored an array because a) the number of elements will be variable, and b) you don't want to reference them by a key.
__________________
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 |
|
#3
|
||||
|
||||
|
thx got it
what a pain it was. ![]() Last edited by Alas : May 7th, 2005 at 02:46 AM. Reason: thx |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Whats difference between structure and array? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|