implemented foreach. (each)

This adds a foreach method. Method signature is "each" because "foreach" cannot be used as it is a reserved keyword in php.