supanoob Posted March 17, 2009 Share Posted March 17, 2009 I have a system where people can add their favourite sites to my database and people can rate them and comment on them. However i want to check the URL on submittion and if it has http:// at the beginning i want it to remove it. I would also like remove anything after the .com or .co.uk or whatever at the end of the URL so it is taking you directly the to homepage instead of allowing links to images etc. How would i do this? Link to comment https://forums.phpfreaks.com/topic/149824-solved-urls-remove-and-check-parts/ Share on other sites More sharing options...
friedemann_bach Posted March 17, 2009 Share Posted March 17, 2009 There is a nice function to parse the components of an URL: http://www.php.net/manual/en/function.parse-url.php You need to extract the host component: parse_url($url,PHP_URL_HOST) So that echo parse_url ('http://www.php.net/manual/en/function.parse-url.php',PHP_URL_HOST); will output "www.php.net" Link to comment https://forums.phpfreaks.com/topic/149824-solved-urls-remove-and-check-parts/#findComment-786752 Share on other sites More sharing options...
supanoob Posted March 17, 2009 Author Share Posted March 17, 2009 There is a nice function to parse the components of an URL: http://www.php.net/manual/en/function.parse-url.php You need to extract the host component: parse_url($url,PHP_URL_HOST) So that echo parse_url ('http://www.php.net/manual/en/function.parse-url.php',PHP_URL_HOST); will output "www.php.net" Didnt know about that, thank you Link to comment https://forums.phpfreaks.com/topic/149824-solved-urls-remove-and-check-parts/#findComment-786756 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.