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
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://
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.