Jump to content

dynamically adding links to content


pgsjoe

Recommended Posts

this could be a waste of time and I apologize if it's already common knowledge. I was hoping there was a function that would make it as simple as:
* scanning a field
* if http://, www, or @ exist to turn the surrounding into a link

Tried searching on google as well as the forums, but could not figure out the correct terms to search on. Does this function exist, if so, where...oh where do I find it?!
Link to comment
https://forums.phpfreaks.com/topic/21996-dynamically-adding-links-to-content/
Share on other sites

If someone enters in a paragraph of text with two or three links, as well as an e-mail address on my form and into the SQL database; in straight text format, no html on it whatsoever. Is there a function that I can use to scan the text and if anything is suppose to be a link, then to turn it into a link.

Something like....

[code]if (www) {
    $linktext = take remainder of text through ".com" (or whatever extension) to to the next space;
    echo '<a href="' . $linktext . '" target="_blank">' . $linktext . '</a> ';
    }

if (@) {
    $emailtext = read text before @ symbol to a space, read text after @ symbol through next space.
    echo '<a href="mailto:' . $emailtext . '">' . $emailtext . '</a>';
    }[/code]

And the same for http://

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.