Просмотр поста

.
ДоХтор
# Udesign (28.01.2017 / 22:35)
ДоХтор, Тепер работает ну тепер выводит толка @Udesign a test не выводит допустим я напишу сообщения вот так Привет @Admin должно выводит Привет <a href="http://sayt.ru/users/profile.php?user=1">Admi
Вот
$url = 'Привет @Admin'; 
 
if (preg_match('~@([\w]+)~iu', $url, $match)) {
    
    $query = mysql_query("
        SELECT * FROM `users` 
        WHERE `name` = '". $match[1] ."'
    ");
    
    $ud_st = mysql_fetch_assoc($query);
    
    $repl = '<a href="http://'. $_SERVER['HTTP_HOST'] .
        '/users/profile.php?user='. $ud_st['id'] .'">'. 
        $match[0] .'</a>';
    
    echo str_replace($match[0], $repl, $url);
}