How to use arrays to return strings

 
I have the following code as below, the issue is when I run it it says array out of range, can someone help me, I am trying to learn MQL5. Thanks in advance
string array_check()
{
 string array1[1,4];
 
 array1[1,1]="AA";
 array1[1,2]="BB";
 array1[1,3]="CC";
 array1[1,4]="DD";
 
 array1[2,1]="AA1";
 array1[2,2]="BB1";
 array1[2,3]="CC1";
 array1[2,4]="DD1";
 
 string result=array1[1,2];
 return result;
}
 
Jones John: I have the following code as below, the issue is when I run it it says array out of range, can someone help me, I am trying to learn MQL5. Thanks in advance

Array index starts at 0, not 1, and the size of the first dimension should be 2 and not 1.

string array_check()
{
 string array1[2,4];
 
 array1[0,0]="AA";
 array1[0,1]="BB";
 array1[0,2]="CC";
 array1[0,3]="DD";
 
 array1[1,0]="AA1";
 array1[1,1]="BB1";
 array1[1,2]="CC1";
 array1[1,3]="DD1";
 
 string result=array1[0,1];
 return result;
}
 
Fernando Carreiro #:

Array index starts at 0, not 1, and the size of the first dimension should be 2 and not 1.

Thank you so much

 
Fernando Carreiro #:

Array index starts at 0, not 1, and the size of the first dimension should be 2 and not 1.

And if I may ask Fernado, what if I wanted to put the array1[0] all inputs in one line?

 
Jones John #: And if I may ask Fernado, what if I wanted to put the array1[0] all inputs in one line?
string array_check()
{
   static string array1[ 2, 4 ] = { { "AA", "BB", "CC", "DD" }, { "AA1", "BB1", "CC1", "DD1" } };
   string result = array1[ 0, 1 ];
   return result;
};
The use of "static" is so that it only initialises the array once and not on every call to the function.
Reason: