Concatenate a placeholder after a for loop end

I am running a for loop in a two-dimensional array and saving that array value in a string. But I need to send that data to the server and display it in a web page later, so my plan is to concatenate a "]" after the end of a 2-dimensional array so I know which is the first column of data. and each value should be separated by commas.so output should be like this

21041D342895,59,2]
8647234AF0D0,59,1]

So Here What I Did

String maclist[64][3]; in this array Data is present 
String MacToEsp32 = "";
//===== LOOP =====//
void loop() {
  for(int i=0;i<=10;i++){
    for(int j=0;j<=2;j++){
      if(!(maclist[i][j] == "")){
       String Data =  maclist[i][j];
       MacToEsp32 +=Data + ",";
       delay(100);
      }
    }
      MacToEsp32 +="]";

  }
    Serial.println(MacToEsp32);   

}

And I am getting an output as

]]]]]]]]]]]B21041DB2895,59,1,]]]]]]]]]]]B21041DB2895,59,2,]1864726AF0D0,59,1,]1864726AF0D1,59,1,]1864726AF0D2,59,1,]C8B37347D63

And I am trying to get a data like this .

R21041DB2896,59,1]821041GB2885,59,2]186472ARFA,59,1]1864726ADSD1,59,1]18SDA6AF0D2,59,1]

What exactly is the layout of the maclist array ?

Does it look like this ?

String maclist[][2] = {{"21041D342895,59,2"}, {"8647234AF0D0,59,1"}};

or something else ?

I was able to figure it out

for(int i=0;i<=15;i++){
    
    if(!(maclist[i][0] == "")){
      MacToEsp32 +="<";
      for(int j=0;j<=2;j++){
      
        
        if (!(j == 2 )) {
          String Data =  maclist[i][j];
          
          MacToEsp32 +=Data + ",";  
        }else {
          String Data =  maclist[i][2];
          MacToEsp32 +=Data + "]>"; 
        }

                 
      }
      if(!(maclist[i][0] == "")) {
      //Sending Data To Another Esp32 
      Serial.println(MacToEsp32);
      SerialPort.print(String(MacToEsp32));

      MacToEsp32 = "";
      Serial.println("Maclist buffer cleared ");

    }   
       
    }
    
  }

thank you

this is an awkward explanation

don't know if you're aware that there's a difference between an array of chars, which is a string and a "String" which is a higher level object that handles strings (e.g. "this is a string").

so above looks like a 2 dimension array of Strings which might be thought of as a 3-dimensional array of chars. if this were char arrays, it would be 64, 3 byte arrays.

sounds like you want an array of char string. below is a 2 dimensional array of chars, 3 singular arrays 64 bytes long.

char charArrays [3][64];

the following code tries to simulate what i think you're trying to do by statically initializing a 2-dimensional char array. statically initialize means the values are pre-defined in the source. presumably you want to capture the data at run time

this is an awkward definition because it defines the length of each array string as 20. the "[]" means the # of values specified will determined that dimension of the array

each c-string is also terminated with a NUL, '\0'

char data [][20] = {
    "R21041DB2896,59,1",
    "821041GB2885,59,2",
    "186472ARFA,59,1",
    "1864726ADSD1,59,1",
    "18SDA6AF0D2,59,1",
    ""
};

with this structure, NUL terminated char arrays or c-strings, the strcat() can be used to concatenate strings together (code below and output following

void concat ()
{
    char s [100] = "";
    for (int n = 0; '\0' != data [n][0]; n++)  {
        char *t = & data [n][0];
        Serial.print   ("  ");
        Serial.println (t);
        if (0 < n)
            strcat (s, "]");
        strcat (s, t);
    }
    Serial.println (s);
}

void setup ()
{
    Serial.begin (9600);
    concat ();
}

void loop ()
{
}

Output

  R21041DB2896,59,1
  821041GB2885,59,2
  186472ARFA,59,1
  1864726ADSD1,59,1
  18SDA6AF0D2,59,1
R21041DB2896,59,1]821041GB2885,59,2]186472ARFA,59,1]1864726ADSD1,59,1]18SDA6AF0D2,59,1