Jump to content

Recommended Posts

I've googled it and of course, it returns ten thousand pages (slight exageration). There's only a few mentions of it returned from a search here and the help file expects that you're programming literate which I am not, obviously. :lol:

I think that only 1 value can be stored in each element of a multi-dimensional array.

eg.

$myArray[1][1] = "Test"
$myArray[1][2] = "Test2"

Right? Well, if that's true I'm lost. :ph34r:

For some unknown reason (see excuse below) I thought you could put multiple pieces of data in a multi-dimension array.

eg.

$myArray[1][1] = "Test","Test2"

As if each dimension represented its own element. In my head the above example meant that $myArray[1] = "Test" and $myArray[1][1] = "Test2". But I'm pretty sure that I'm wrong on how that works. From what I've gathered playing around with it you have to use both dimensions (if it's 2 dimensional) to get the value stored in the element.

I've come across a problem that I'm trying to solve and I thought a multi-dimension array was the way to go until I read the sample in the help file. I have a chart that I'm trying to find points on. Put it this way:

I have a line chart that graphs some information. Each point on the graph represents 5 pieces of information. I'm not sure how to store all the variables. I guess I can store them in a multi-dimensional array and seperate the data by "," or something and then do a stringsplit on them.

How did I get hung up on multi-dimension arrays? I saw it in the help file and it used rows and columns in the example, which is what I'm working with. :(

[Excuse]I don't know what I was thinking... it was 3 in the morning. That's my excuse and I'm stickin' with it![/Excuse]

Bottom line: Can someone point me to a decent example and explanation of multi-dimension arrays? Book references are good, but I don't own that many programming books so I'd rather have www references.

TIA!

Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow.
Link to post
Share on other sites

Think of a single dimention like a list. Each element in your list can be a piece of data (such as a string or number.)

A 2-dimention array should be thought of like a matrix (remember those from math class?) That way each "box" in the grid that you form in your mind can store a piece of data. Sometimes it helps to think of a piece of graph paper.

You can keep going for as many dimentions as you're using. A 3 dimentional array can be thought of as a rectangular prisim, each "cube" being able to hold an element. Most people get lost around 4 or 5 dimentions because it get harder and harder to conceptualize, but at this point you would probably resort to using lines on paper and drawing each array as a "tree" off of the previous array.

To access a 2-dimentional array element, you need 2 index number. So, if I created an array using Local $array[5][5] this would give me a 5 by 5 matrix (which is an array of arrays.) The upper left element of the matrix would be $array[0][0] and the lower right element would be $array[4][4]. For more than 2 dimentions, you just stack on more index numbers seperated by brackets.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Link to post
Share on other sites

After reading a few web pages and your post I understand them better.

Thanks again. I'll just have to use stringsplit to put multiple pieces of data in my 2 dimension array.

Raoul S. Duke: Few people understand the psychology of dealing with a highway traffic cop. Your normal speeder will panic and immediately pull over to the side. This is wrong. It arouses contempt in the cop-heart. Make the bastard chase you. He will follow.
Link to post
Share on other sites

After reading a few web pages and your post I understand them better. 

Thanks again.  I'll just have to use stringsplit to put multiple pieces of data in my 2 dimension array.

take care,

Stringsplit is just filling a one dimension array not a 2. :ph34r:

Link to post
Share on other sites

cols

|0|1|2|3|4|

|0|x|a|q|g|n|

|1|a|x|g|n|q|

row |2|g|n|a|q|x|

|3|n|a|x|a|b|

|4|b|a|d|a|z|

array[0][3] = g

just to let you know that it starts with 'zero'

so a list with 5 rows and columns is exactly what you see above

oh yah and read the post above hehe :ph34r:

------------------------------------------------------------------If it were up to me, all computer stuff would work

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...