BillyBoB Posted December 17, 2006 Share Posted December 17, 2006 I have a news database and i was wondering if i could somehow make it where when if fetches the array if it could search it and put it in a <a href=$link >$link</a> and make it where if it allready has the tag <a href= > and </a> then do nothing this is probably a longer anwser but if som1 could plz help that would be much appreciated Quote Link to comment https://forums.phpfreaks.com/topic/30948-quick-question-on-finding-if-its-a-link-in-a-string/ Share on other sites More sharing options...
.josh Posted December 17, 2006 Share Posted December 17, 2006 [code]<?php// assuming your data looks like this vs. this:// http://www.blah.com vs. <a href='http://www.blah.com'>http://www.blah.com</a>// example$data = "http://www.blah.com";// data have '<a' in it already? do nothing. It doesn't? add it on$data = (stripos($data, "<a")) ? $data : "<a href = '$data'>$data</a>";[/code] Quote Link to comment https://forums.phpfreaks.com/topic/30948-quick-question-on-finding-if-its-a-link-in-a-string/#findComment-142822 Share on other sites More sharing options...
BillyBoB Posted December 17, 2006 Author Share Posted December 17, 2006 im trying for somin like it searches a array then it tells me if there is a site from searching for http:// or .com or .net etc... then adding Quote Link to comment https://forums.phpfreaks.com/topic/30948-quick-question-on-finding-if-its-a-link-in-a-string/#findComment-142840 Share on other sites More sharing options...
.josh Posted December 17, 2006 Share Posted December 17, 2006 uh..okay..well you didn't say anything about that in your OP. And even now you're not being very specific. The impression I got is that you have a chunk of data and it has a url in it somewhere but it may or may not have href tags around it, so if it doesn't, then wrap the url in href tags. That's what my example does. If you have an array of data, just put the code in a loop that checks each element. How about you make an example list of what your actual data looks like and post it here, showing [i]every[/i] example of what it should look for and change, vs. not change. Quote Link to comment https://forums.phpfreaks.com/topic/30948-quick-question-on-finding-if-its-a-link-in-a-string/#findComment-143011 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.