Issue dynamically accessing an array of integers

Hello All,

I'm trying to access an array of integers dynamically, and I'm having issues were I am getting garbage data. The array is stored in PROGMEM, and if I try to access it with a hard coded line, it works fine. However, if I say I want to get data at some variable position, it gives me some random huge integer. Below is some of the code:

int const cursordata [15][6] PROGMEM = //first number selects the x, the second number selects the y, third number selects the entry. First entry is the number of cursor positions on screen. The next 4 are the positions of those cursors.
{
{ //this block exists on Idle Screen level level 0
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
},
{ //this block exists on the Main Menu level level 1
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{1, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0}
}, etc etc

int intdisplayline[3] = {1,0}; //x, y of display
int intcursorpos[4] = {0,0,1}; //Used in determining display cursor position on the screen, x, y, logical position (1-4)

And later in the program...

int intcursorpos[0] = cursordata[intdisplayline[0]][intdisplayline[1]][intcursorpos[2]];

Serial.print("Displayline X: "); Serial.println(intdisplayline[0]);
Serial.print("Displayline Y: "); Serial.println(intdisplayline[1]);
Serial.print("Cursor X: "); Serial.println(intcursorpos[0]);
Serial.print("Cursor Y: "); Serial.println(intcursorpos[1]);
Serial.print("Cursor Logical: "); Serial.println(intcursorpos[2]);
lcd.setCursor(intcursorpos[0], intcursorpos[1]);
lcd.print(">"); //Prints cursor

If I run this code, my intdisplayline[0] and [1] are 1 and 0 respectively, and my intcursorpos[2] is 1, which should give me a value of "0", but instead I get "21504", which is garbage. However, if I replace my intcursorpos[0] = code with "int intcursorpos[0] = cursordata[1][0][1];", I get "0" as expected.

I have a feeling I'm missing something with pointers, which I seem to have a heck of a time with, but I'm not sure. Any help would be appreciated, thanks!

Please use code tags instead of quote tags; you can edit your post.

// edit
And post complete code please

// edit 2
See progmem reference how to access PROGMEM.

What everyone else said. Progmem addresses look like regular addresses to C++, but they aren't actually in regular memory. Using simple dereferencing (*, ->, ) will get data from the same address in regular memory, which as you have discovered contains unrelated stuff.

Use the progmem functions and helpers to get at your data.