dreamwest Posted June 10, 2009 Share Posted June 10, 2009 Im trying to filter out url from going into the database $search = "http://www.site.com"; if ($search is url ){ echo "search is a url"; }else{ mysql_query("INSERT INTO tags (tag) VALUES('".$search."' ) ") or die(mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/161603-check-if-url/ Share on other sites More sharing options...
chronister Posted June 10, 2009 Share Posted June 10, 2009 Your going to want to use some regex (regular expression).. http://www.the-art-of-web.com/php/parse-links/ <?php $search = "http://www.site.com"; $pattern ='/<a href=\"([^\"]*)\">(.*)<\/a>/iU'; preg_match($pattern, $search, $matches); if(count($matches) > 0){ echo 'URL found'; } ?> This is a basic example... take a look at the link I gave for a more complicated example. Nate Quote Link to comment https://forums.phpfreaks.com/topic/161603-check-if-url/#findComment-852778 Share on other sites More sharing options...
dreamwest Posted June 10, 2009 Author Share Posted June 10, 2009 Excellent. Thanks Its alot like htaccess expressions Quote Link to comment https://forums.phpfreaks.com/topic/161603-check-if-url/#findComment-852784 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.