Hi,This code creates a friendly link on user mentions in comments...
However, it is not case sensitive and vice versa.
Examples;
@test works
@Test doesn't work
What do I do?
text = "@test @Test";
$pattern = "/\@(\w+)/"; preg_match_all($pattern,$text,$matches);
if($matches){
$sql = "SELECT * FROM users WHERE username IN ('" .implode("','",$matches[1]). "')"; $user = $link->query($sql);
foreach($user as $i=>$u){
$text = preg_replace("/@".$u['username']."\b/",
"<a href='#' title='{$u['user_id']}'>@{$u['username']}</a> ", $text);
}
echo $text;
}