Closed. This question needs
details or clarity. It is not currently accepting answers.
Answer
Solution:
You probably want to exclude space and @
:
$string = preg_replace('#@([^\s@]+)#', '<b><a href="$1"> @$1 </a></b>', $string);
Answer
Solution:
Try this
$atPosition = stripos($string, '@');
$substr = '';
if (stripos($string, '@') !== false) {
$substr = substr($string, $atPosition + 1);
$content = '<b><a href="'.$substr.'"> '.$substr.' </a></b>';
}
echo $content;
Source