Retrieve and tidy up one directory name in a url. e.g. I need example.com/main/this_dir/page.html to output as "This Dir"
<p>I am stuggling to comprehend how to accomplish the following task "</p>

<p>From : <code>http://www.example.com/main/this_dir/page.html</code></p>

<p>I would like an output of : <strong>This Dir</strong></p>

<p>When using <code>$_SERVER['REQUEST_URI']</code> i can get this output :</p>

<p>*/main/this_dir/*</p>

<p>I would like to now take that and strip the last string between the two /'s so i end up with</p>

<p>*this_dir*</p>

<p>I would then like to take that string and turn it into </p>

<p><strong>This Dir</strong></p>

<p>There is a slight complication with this too because the directory could simply be called /this/ and not /this_dir/, but it is always one or the other and the text does change whereas the words i used were merely an example.</p>

<p>If anyone has any suggestions, input or feedback as to how i could accomplish this task it would be greatly appreciated! I do have a vague idea of how i could strip the last directory name from the request_uri string but i would really like to know if it would even be possible to transform the string in the way that i have described, using PHP.</p>
