How do I make a URL text a link?
- by jpjp
Say on Facebook or Twitter, when I type "www.google.com" and submit it, it becomes a link. How do I code this in PHP? Do I use regular expressions to get where the www starts and the .com ends?
Is this how they do it?
<?PHP
//some regular expression to get www and .com part
$link="<a href='$url'>$url</a>";
echo $link;
?>
How do I write a regular expression to get the "www" and ".com" part?
And for twitter's @obama, obama would become a link to obama's site.
What regular expression do they use to get the text after the @ and before the space?