ram's answers

A foreach loop tends to be better when you want to operate on all the elements of an array. while loops are better when you don't know how many times you want to iterate.