array function with foreach