Ho corretto così, ma in pratica mi riconosce i tag, ma non mette il relativo link al profilo:

Codice PHP:
public function GetTag ($text) {
        
$matches = array();
          
$replacements = array();
          
preg_match_all('/#([^\s]+)/'$text$matches);
        
        
$this->DBConnect();
        
$sql mysql_query("SELECT * FROM users");
        while (
$rows mysql_fetch_array($sql)) {
            for (
$j 0$c count($matches[1]); $j $c$j++) {
                
$str strtolower(str_replace(' '''$this->GetNameSurname($rows['id'])));
                if (
$str == $matches[1][$j]) {
                    
$replacements[$j] = "[url='profile.php?user=".$rows[']".$this->GetNameSurname($rows['id'])."[/url]";
                } else {
                    $replacements[$j] = $matches[1][$j];
                }
            }
        }
        for ($j = 0, $c = count($matches[1]); $j < $c; $j++)
            $text = str_replace($matches[1][$j], $replacements[$j], $text);

          return $text;
        
    }