Answer the question
In order to leave comments, you need to log in
Help with a regular routine?
I'm bad at them.
In general, text is written to the database, it looks like this there:
Then I display it on the page, having previously processed the links in the form of links and using the nl2br function:
function changeTextToLink($text){
$text = preg_replace("/(^|[\r\n ])([\w]*?)((www|ftp)\.[^ \,\"\t\n\r<]*[^ \.])/is", "$1$2<a href=\"http://$3\" >$3</a>", $text);
$text = preg_replace("/(^|[\r\n ])([\w]*?)((ht|f)tp(s)?:\/\/[\w]+[^ \,\"\n\r\t<]*[^ \.])/is", "$1$2<a href=\"$3\" >$3</a>", $text);
return($text);
}
$text = changeTextToLink($data["text"]);
$nl2 = nl2br($text);
echo $nl2;
http://mysite.ru/rules<br />
- naturally incorrectly opening Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question