The do...while() is inside a foreach(), so it is 2-dimensional and works as intended.