Lamez Posted October 9, 2008 Share Posted October 9, 2008 How do I break down a string? I have a External Link Checker(http://links.krazypicks.com), which will check to see if the URL is in the blacklist that is in the database, but if it is not then it will show a continue warning. Well I want to know how to break down the URL. say they type this in: I want to break it down to www.youtube.com, to check, then display the real URL. Does this make sense? You can just give me a function. -Thanks Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted October 9, 2008 Share Posted October 9, 2008 Regular Expression is what you are looking for. http://www.webdeveloper.com/forum/showthread.php?t=56225 What I found with google. Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 9, 2008 Author Share Posted October 9, 2008 however, I did use "the google", but that does not help at all. is there a function. Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 9, 2008 Share Posted October 9, 2008 parse_url(). Read up about it in the PHP manual. Quote Link to comment Share on other sites More sharing options...
Lamez Posted October 9, 2008 Author Share Posted October 9, 2008 ok so I have this bit: <?php $link = print_r(parse_url($url)); ?> but it is echoing out, and I know it is in an array, but how to I take it out? here is an example of the out put: Array ( [scheme] => http [host] => www.youtube.com [path] => /watch [query] => v=Cqsrq34qDyk ) how can I just echo out the host? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted October 9, 2008 Share Posted October 9, 2008 <?php $link = parse_url($url); $host = $link['host']; ?> Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted October 9, 2008 Share Posted October 9, 2008 Damn we all learn something new everyday... Guess some people just don't know it. Also reading up on it you could also just do: <?php $host = parse_url($url, PHP_URL_HOST); ?> Quote Link to comment 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.