timmah1 Posted May 30, 2008 Share Posted May 30, 2008 I have a form that inserts domain names into a database field. The domain name could be simple (http://www.test.com/hi/) or complex (http://cgi.ljx.com/cgi-bin/memo/show?articleid=hunton,23) When I pull this information from the database, how can I just show the domain (http://www.test.com or http://www.ljx.com)? Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/108008-solved-strip-name/ Share on other sites More sharing options...
thebadbad Posted May 30, 2008 Share Posted May 30, 2008 <?php $url = 'http://cgi.ljx.com/cgi-bin/memo/show?articleid=hunton,23'; $url_info = parse_url($url); echo $url_info['scheme'], '://', $url_info['host']; // http://cgi.ljx.com ?> Link to comment https://forums.phpfreaks.com/topic/108008-solved-strip-name/#findComment-553598 Share on other sites More sharing options...
paulman888888 Posted May 30, 2008 Share Posted May 30, 2008 <?php //chanhe domainname to the form data you want $url = echo $_POST['domainname']; $url_info = parse_url($url); echo $url_info['scheme'], '://', $url_info['host']; // Getting form data ?> Link to comment https://forums.phpfreaks.com/topic/108008-solved-strip-name/#findComment-553601 Share on other sites More sharing options...
timmah1 Posted May 30, 2008 Author Share Posted May 30, 2008 Exactly what I was trying to do thebadbad. I'm know starting to understand parse_url after seeing a working example Thank you. Link to comment https://forums.phpfreaks.com/topic/108008-solved-strip-name/#findComment-553608 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.