If I have a URL that is http://www.example.com/sites/dir/index.html, I would want to extract the word \"sites\". I know I have to use regular expressions but for some reason my
The dirname function should get you what you need
http://us3.php.net/manual/en/function.dirname.php