I want to get a text in the form of input that output.
My draft is as follows:
function automatically links ($ text) {return preg_replace ('/ https :? / \ / [\ S] + / I, '& Lt; a href = "\ 0" & gt; \ 0 & lt; / a & gt;', $ text); }
But it does not work properly.
For input text in which ...
http: //www.google.de/
... me The following output is available:
& lt; A href = "http://www.google.de/
& gt; Http: //www.google.de/< Br & lt; / A & gt; / & Gt;
Why does it include line breaks? How can I limit it to the real URL?
Thanks in advance!
OK, & lt;
is not a white space character, so you can exclude it from your set of approved characters:
preg_replace ('/ https?: \ / \ / \ ^ & Lt;] + / i ',' & lt; a href = "\ 0" & gt; \ 0 & lt; / a & gt; ', $ text);
Comments
Post a Comment