Yes, it works as it highlights the address.
But, there is a problem now when there is more that one link in the text field.
For example:
Input:
LIST OF SOURCES:
1.
http://www.media-awareness.ca
2. See info at
http://p2p.wrox.com
Print:
LIST OF SOURCES:
1. http://www.media-awareness.ca<BR< a> /> 2. See info at http://p2p.wrox.com<BR< a> /> (with one link to both addresses)
My code is:
//I take text from db field
$fieldg = nl2br(htmlspecialchars($row['field_g']));
$words = preg_split("/[\s,]+/",$fieldg);
for($i = 0; $i < count($words); $i++)
{
if(substr($words[$i],0,7)=="http://" || substr($words[$i],0,8)=="https://"){
$words[$i] = "<a href='$words[$i]'>$words[$i]</a>";
}
}
//convert array to string
$strbody7 = implode(" ", $words);
echo $strbody7;
I tried to remove nl2br(htmlspecialchars from line
$fieldg = nl2br(htmlspecialchars($row['field_g']));
then it gives me the following unformatted output:
LIST OF SOURCES: 1.
http://www.media-awareness.ca 2. See info at
http://p2p.wrox.com
Could you please help to solve this problem with correct formatting output of links?
Thank you,