Can I access an array using a variable?
Posted: Tue Sep 26, 2017 5:43 am
Hi all, need some guidance. I'm trying to set up something like a 2D array but not sure how.
All the arrays are of the same length. There will be an underlying condition that determines whether array1, array2, or array3 is accessed. The input will contain some form of text, and this text exists in one of the elements of arrayHeader. My initial plan was the input will give me the index in arrayHeader, so that takes care of the column. But I do not know how to get the row. The conditions generate a string, like array2, but I can't use that string to access the array. I'm probably doing it the wrong way. Please guide. Thank you.
Code: Select all
arrayHeader = [...]
array1 = [...]
array2 = [...]
array3 = [...]
Code: Select all
userInput > find the index in arrayHeader > needleIndex
conditions return array2 > needleArray
need to access needleArray[needleIndex]