in reply to Getting a result from "foreach" block
Or, for more general cases, simply use foreach, and/or the each() function, to control an ordinary loop, and do whatever needs to be done within that loop. The aforementioned functions are of course very efficient and are great for avoiding the necessity of explicit loops. Feel free to do it either way as suits the occasion.