prova con:
Codice PHP:
echo "<a href=\"".$str[$key]."\">".$data[$key]."</a>
"

o

Codice PHP:
echo "<a href=\"".$string."\">".$data[$key]."</a>
"

PS: io non userei variabili chiamate string non si sa mai..