PHP - Getting a current directory
<p>I'll set the scene...</p>

<ol>
<li>I've got a file <strong>example.php</strong></li>
<li>That particular file is in a folder called <strong>test</strong></li>
<li>The full file path is /root/user/website/htdocs/test/example.php</li>
</ol>

<p>What I'd like is to echo the directory the file is in ie. <strong>test</strong></p>

<p>I've managed to do this by reading the functions and creating the script below, is this a bad way of going about this? is there an easier way?</p>

<pre><code>&lt;?php
$dir_array = explode('/', getcwd());
$dir_current = end($dir_array);

echo $dir_current;
?&gt;
</code></pre>

<p>outputs <code>test</code></p>

<p>Thanks in advance.</p>
