Jump to content


Photo

dynamically adding links to content


  • Please log in to reply
2 replies to this topic

#1 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 25 September 2006 - 03:50 PM

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

#2 steveclondon

steveclondon
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 25 September 2006 - 04:36 PM

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

#3 pgsjoe

pgsjoe
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 25 September 2006 - 04:53 PM

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

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>';
     }

And the same for http://




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users