in reply to looping in 2d array

Some general points which do not address the OPed question (BTW: I think hippo is on the mark with the observation that  $i3 is never used), but may be of interest: