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! 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". 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! 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
Archived
This topic is now archived and is closed to further replies.