marketinggallery Posted April 15, 2008 Share Posted April 15, 2008 Currently I'm using the following code, which allows a url to be clickable: <?= makeClickableLinks(str_replace(chr(13),strip_tags($rshome["article_summary"],")));?> This is the section from the function page: function makeClickableLinks($text) { $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','<a href="\\1" target=_blank>\\1</a>', $text); $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1<a href="http://\\2" target=_blank>\\2</a>', $text); $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', '<a href="mailto:\\1">\\1</a>', $text); return $text; } When I type out text to include a hyperlink, such as <a href= "http://www.mysite.com/thispage.htm">display text</a> it will NOT display the clickable link. How do I modify the php/html to allow it to read the link properly? Any help would be much appreciated! Thank you. Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/ Share on other sites More sharing options...
amites Posted April 15, 2008 Share Posted April 15, 2008 are you typing in the full link HTML or just the URL? seems to want just the URL, could also have something to do with the <? vs <?php <? does not execute PHP unless told to specifically on the server Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-518018 Share on other sites More sharing options...
Cosizzle Posted April 15, 2008 Share Posted April 15, 2008 Try putting </a> instead of </url> Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-518020 Share on other sites More sharing options...
marketinggallery Posted April 16, 2008 Author Share Posted April 16, 2008 I am typing out the full html string, since I want the clickable text to display different then the actual link. I checked the code and I do have <?php at the top of the function. It also has <a> and </ a> shown correctly. Looks like the code defaulted to </url> when I posted it here... If I type any url, it becomes clickable okay, just not when I type in an <a href> string like my example above. Any other suggestions? Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-518105 Share on other sites More sharing options...
Northern Flame Posted April 16, 2008 Share Posted April 16, 2008 Try putting </a> instead of </url> this forum automatically puts </url> instead of </a>, nothing to do with his code.... As for your code, im looking but I dont see a problem, ill keep on trying to come up with a solution though Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-518116 Share on other sites More sharing options...
redarrow Posted April 16, 2008 Share Posted April 16, 2008 Have a look and try............ <?php $l=array("www.html.com","http://www.msn.co.uk","www.fool.com","http://www.google.co.uk","http://www.yahoo.com"); foreach($l as $link){ if(PREG_MATCH("/^(http)(\:\/\/(w){3}\.)[a-zA-Z](.?)[a-zA-Z]{2,3}/",$link)){ echo "<font color='blue'>Link correct $link </font> <br><br>"; }else{ echo "<font color='red'>link incorrect $link </font><br><br>"; } echo "<a href='$link'>$link</a><br><br>"; } ?> Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-518129 Share on other sites More sharing options...
marketinggallery Posted April 16, 2008 Author Share Posted April 16, 2008 RedArrow- I tried your code above, no luck. The site wouldn't display correctly and it didn't recognize the links shown in your example. It's got to be the function string and how it's reading and interpreting the url / html data Any other ideas are appreciated. Thanks much! Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-518388 Share on other sites More sharing options...
marketinggallery Posted April 17, 2008 Author Share Posted April 17, 2008 Can anyone else offer a solution for my problem? Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-519585 Share on other sites More sharing options...
marketinggallery Posted April 22, 2008 Author Share Posted April 22, 2008 I found a solution from someone at ScriptLance.com Thanks to all who offered to help! Link to comment https://forums.phpfreaks.com/topic/101271-need-help-with-hyperlinks-code/#findComment-523894 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.