In other words, for the first line,
* the m is 0 initially
* 0 < array1[0] (==5), so one char prints and m increments
* 1 < array1[1] (==2), so one char prints and m increments
* 2 is not < array[2] (==1), so the loop should end
There is something fishy in the data, for your stated data should print only two * for each row.
Why for each row? Because you do compare the loop counter to array1[m]. Should you not use the ith value for the entire row i?