I need to take a list of URLs like this for example:
www.mysite.com all about my site
whatever.net things and stuff
http://www.mycoolsite.com cool, coolness, and cool stuff
randomsite.org
RadStuff.com
and turn them into a list of links. If there are keywords like some of the above have, the keywords or phrases should be the link without the URL being shown. If no keywords are specified, it should go ahead and show the URL as a link.
I have like 1000 URLs so I need this to be automated.
I'm a novie at PHP and regex confuses the hell outta me, but here's what I have so far:
So I have a form where I paste my URL list, and it outputs the URLs as links. I can't figure out how to get the keywords to be links without showing the URLs!
So how do I get this working?
www.mysite.com all about my site
whatever.net things and stuff
http://www.mycoolsite.com cool, coolness, and cool stuff
randomsite.org
RadStuff.com
and turn them into a list of links. If there are keywords like some of the above have, the keywords or phrases should be the link without the URL being shown. If no keywords are specified, it should go ahead and show the URL as a link.
I have like 1000 URLs so I need this to be automated.
I'm a novie at PHP and regex confuses the hell outta me, but here's what I have so far:
PHP:
<?php>
$urls=$_POST['urls'];
$urls=str_replace('http://www.', 'http://', $urls);
$urls=preg_replace("/(?:(http:\/\/)|(www\.))(\S+\b\/?)([ [:punct:]]*)(\s|$)/i",
"<a href=\"http://$2$3\">$1$2$3</a>$4$5", $urls);
$urls=stripslashes($urls);
echo $urls;
?>
So how do I get this working?