RISOLTO, GRAZIE

Codice PHP:
$text $_POST['post'];
$text preg_replace('/#([\w]+)/''[url="http://127.0.0.1:8887/tag.php?q=$1"]#$1[/url]'$text);            
$cerca preg_match_all('/#([\w]+)/'$text$tag);
print_r($tag[1]);
$tag implode($tag[1]);