How to get every variable of loop into an array and call all the variables in some other variable.

I am very new to array. I don't have any idea how to solve this.

Suppose I have an `Array[]`

and the variable in an array is `i`, so `i1, i2, i3 ....... in` 

`n` is the number of times loop will run.

So

```
for (i=1; i<=n, i++) {

//I need an array called here.

//there will be some code play here

//There will be some value returned after the code it could be text or no.

}

```

then I want to assign all the values of array into a variable with comma separated

```
var k = array{}  i.e k = "i1,i2,i3,......in"

```

I try to find on Google but not able to find any solution.

This example is a reference for what I want to achieve actually.