![]() |
![]() |
||||||
|
|||||||
| Tags: |
![]() |
|
|||
|
What's the problem with my array code attached, figure they have been around
for so many years I should probably learn how to use them. <cfset my2darray=arraynew(2)> <cfset my2darrry[1][1] = "Catalog Title"> <cfset my2darrry[1][2] = "Catalog Image"> <cfset my2darrry[1][3] = "Catalog Text"> <cfset my2darrry[1][4] = "Catalog Link"> <cfset my2darrry[2][1] = "Video Title"> <cfset my2darrry[2][2] = "Video Image"> <cfset my2darrry[2][3] = "Catalog Text"> <cfset my2darrry[2][4] = "Catalog Link"> <p>The values in my2darray are currently:</p> <cfoutput> #my2darray[1][1]#<br> #my2darray[1][2]#<br> #my2darray[1][3]#<br> #my2darray[1][4]#<br> #my2darray[2][1]#<br> #my2darray[2][2]#<br> #my2darray[2][3]#<br> #my2darray[2][4]#<br> </cfoutput> |
| Sponsored Links |
|
|||
|
> <cfset my2darray=arraynew(2)>
> <cfset my2darrry[1][1] = "Catalog Title"> You might want to look closer at your code. Also, when you have a problem, it's helpful if you tell us what the problem actually is, not simply say "I have a problem, what is it?". Thirdly: an array is really not the best data structure for you to be using here. It looks more like it should be a struct, or perhaps an array of structures to me. -- Adam |
|
|||
|
Adam Cameron wrote:
>> <cfset my2darray=arraynew(2)> >> <cfset my2darrry[1][1] = "Catalog Title"> > > You might want to look closer at your code. > > Also, when you have a problem, it's helpful if you tell us what the problem > actually is, not simply say "I have a problem, what is it?". Really!!! because even with Adam point out the spot I could not see the problem the first four times I looked at it. Since I did not really know for what I was looking. Knowing the error would have guided me much faster to this issue. > > Thirdly: an array is really not the best data structure for you to be using > here. It looks more like it should be a struct, or perhaps an array of > structures to me. > A valid point, but that sure looks like a foobar|hello world example to practice a new skill and as such is fine. But I agree, if I where looking at a requirement like this I would probably be looking at using a structure, aka a hash array. I.E. using strings as index keys rather then integers. |
|
|||
|
>> <cfset my2darray=arraynew(2)>
>> <cfset my2darrry[1][1] = "Catalog Title"> > Please advise what is the problem with my code? I think the problem is that you're not actually looking at it, as much as anything else. *look at it*. -- Adam |
|
|||
|
> No I was asking you told me to look at my code closely and I was wondering what problem you saw with it as I am unfamilar with arrays and was asking for help.
For goodness sake, mate. What's the name of the variable in this line of code: <cfset my2darray=arraynew(2)> And what's the name of the variable in THIS line of code: <cfset my2darrry[1][1] = "Catalog Title"> Are they the same? No. Do you think perhaps that might be your problem? -- Adam |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
- Contact Us
-|-
Adobe Dreamweaver Forums -|-
Archive -|-
Top -|-Rules/Disclaimer-|-Help/Support-|-Advertise