Subtracting path from document root in PHP
<p>My current document root is this (via $_SERVER['DOCUMENT_ROOT']): </p>

<pre><code>/var/www/html/clients/app/folder
</code></pre>

<p>I need to generate one folder up:</p>

<pre><code>/var/www/html/clients/app
</code></pre>

<p>How would I go about doing this?</p>

<p>I had asked this in the past:
<a href="http://stackoverflow.com/questions/4225254/dynamically-finding-paths-is-there-a-better-way">Dynamically finding paths, is there a better way?</a></p>

<p>However, I have this scenario which doesn't work:</p>

<ul>
<li>Executed script is located here: root/f1/f2/f3/f4/f5/file.php. </li>
<li>This script includes another script located here: root/f6/file2.php</li>
</ul>

<p>In file2.php, I needed the following code for this to work:</p>

<pre><code>$base_path = dirname(realpath("../../../../do_not_remove.txt"));
</code></pre>

<p>When in theory, based on its location, it should have been this:</p>

<pre><code>$base_path = dirname(realpath("../do_not_remove.txt"));
</code></pre>

<p>In practice, there would be a global available where this data could be passed. However, in this inherited project, there isn't thus I'm reusing this where I need it.</p>

<p><strong>Update #1</strong></p>

<p>Based on the answers, this seems to work great: <code>realpath($_SERVER['DOCUMENT_ROOT']."/../../");</code></p>
