Hi, I am trying to strip down a url like this: http://www.website.co.uk/word-word-word/word-word-word.html I just want to extract the bold section above between the / / and remove the - does anyone know how i can do this. Cheers, Adam
This will extract what you want: <?php $url = 'http://www.website.co.uk/word-word-word/word-word-word.html'; $parts = parse_url($url); list($junk, $want, $junk) = explode('/', $parts['path'], 3); echo $want; ?> PHP: Output: word-word-word Code (markup): Jay -- If this post helped, a reputation would be appreciated
Exactly what nico_swd said. Just to confirm, it's: $url = $_SERVER['REQUEST_URI']; PHP: Replace the $url = ... line with that one. Jay