A
A
Arthur2018-07-31 08:37:39
PHP
Arthur, 2018-07-31 08:37:39

Help with a regular routine?

I'm bad at them.
In general, text is written to the database, it looks like this there:
K6fh8tEhWPI.jpg
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;

Everything would be fine, but it turned out that the links are obtained in the form of:
A_Y7L3Mi7kA.jpghttp://mysite.ru/rules<br />- naturally incorrectly opening
Although the display seems to be normal:
QROT5RR8NKI.jpg
Tell me where you screwed up, and if there is some kind of editing on this matter.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question