Answer the question
In order to leave comments, you need to log in
How to wrap a hashtag in a link?
How to wrap a hashtag in a link?
Something like this
#sky #sea
in the code should turn out
<a href="tag/небо">#небо</a> <a href="tag/море">#море</a>
Answer the question
In order to leave comments, you need to log in
$string = '#небо #море';
echo preg_replace('/#([a-zа-я0-9]+)/ui', '<a href="tag/$1">#$1</a>', $string);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question