correct foreach snippet for php