Jump to content


Photo

Creaking a ahref link


  • Please log in to reply
3 replies to this topic

#1 matfish

matfish
  • Members
  • PipPipPip
  • Advanced Member
  • 242 posts
  • LocationUK

Posted 19 August 2006 - 04:19 PM

Hi, hard to explain and not sure if its simply possible..

Say iv got a text feild in the database and im pulling it in so it looks like an article. If someone types in a URL like "This is an www.example.com" how can I make the URL clickable link in the article without them knowing the html tags etc..? I dont want them entering <a href= etc..

Thanks





#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 19 August 2006 - 04:41 PM

yes it can be done
using ereg_replace
<?php
$text = ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
                    "<a href=\"\\0\">\\0</a>", $text);
?>
Tell me the problem, I will try tell you the solution

#3 matfish

matfish
  • Members
  • PipPipPip
  • Advanced Member
  • 242 posts
  • LocationUK

Posted 20 August 2006 - 03:36 PM

Sorry - dont understand?

Tried it and it didnt make any difference...

Thanks

#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 20 August 2006 - 06:23 PM

using the ereg_replace, it will find www.example.com, and replace it with <a hreg='www.example.com'>www.example.com</a>
not that it should be < / a > not [/url]
Tell me the problem, I will try tell you the solution




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users