DrTrans Posted December 1, 2013 Share Posted December 1, 2013 ok so i have a url example" $url = "http://blah.domain.com/directory/INFINITA/76/98/23"; i need to be able to match specifically that its a domain of http://blah.domain.com/directory/, and be able to return the value of " INFINITA " Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted December 1, 2013 Share Posted December 1, 2013 (edited) No need for regex use parse_url $url = 'http://blah.domain.com/directory/INFINITA/76/98/23'; $urlPath = parse_url($url, PHP_URL_PATH); // get the path from the url $segment = explode('/', trim($urlPath, '/')); // explode the path into segments echo $segment[1]; // get the second segment INFINITA Edited December 1, 2013 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
DrTrans Posted December 2, 2013 Author Share Posted December 2, 2013 That would do every url that way that i pass to it. basically what I'm trying to do is... $text = " Im hanging out at http://blah.domain.com/directory/INFINITA/76/98/23" ; $text would return = "Im hanging out at INFINITA " with the "INFINITA" being hyperlinked to the original url. However, if $text = "Go look at this thread: http://forums.phpfreaks.com/topic/284414" it doesn't bother it. 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.