Jump to content

Recommended Posts

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 by Ch0cu3r

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. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.