Jump to content

Archived

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

pgsjoe

dynamically adding links to content

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?!

Share this post


Link to post
Share on other sites
don't know what you really want to do, explain a little more. surely if it is http: or an @ it will already be a link. Do you mean search other peoples sites your scripts????

Share this post


Link to post
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://

Share this post


Link to post
Share on other sites

×

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.