How to pass the array to the loop

A post was split to a new topic: Best way to code this