First 'problem' that jumps out at me is the random whitespace in the code. Are you using an editor that randomly inserts any number of vertical/horizontal tabs at its own discretion?!
Second problem is that you place a variable inside single quotes (e.g. '$key'). Not only is this wrong because single quotes implies that no variable interpolation is done (see this manual page to learn about different ways of constructing strings: [man]string[/man]), but it's wrong because no quotes are needed. If the string consists of nothing but the variable, get rid of the quotes and just leave the variable.