ohdang888 Posted May 25, 2010 Share Posted May 25, 2010 say i have this: $str = "http://blog.example.com/10/234/post/345.html" or anything like this. how would i extract the "http://blog.example.com/" from it? but this is just an example... i need it to work for any subdomain name and any ending (.com, .net, .info, etc) Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/202862-get-site-name-from-url/ Share on other sites More sharing options...
premiso Posted May 25, 2010 Share Posted May 25, 2010 You can try and use parse_url and call the array object like: $parsed['subdomain']; Which should pull out "blog". Quote Link to comment https://forums.phpfreaks.com/topic/202862-get-site-name-from-url/#findComment-1063135 Share on other sites More sharing options...
ohdang888 Posted May 25, 2010 Author Share Posted May 25, 2010 that works! thanks! Quote Link to comment https://forums.phpfreaks.com/topic/202862-get-site-name-from-url/#findComment-1063192 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.