find current directory level with PHP
<p>I need to require_once a file that is located in my sites root directory. The problem I have is that I won't always know how many levels up the root directory is from where my current script is running. So I need to figure out how many directory levels I need to go up to require_once my file.</p>

<p>Some times it could be:</p>

<pre><code>require_once '../../file.php';
</code></pre>

<p>And some times it could be:</p>

<pre><code>require_once '../file.php';
</code></pre>

<p>Or any other number of directory levels up.</p>

<p>How can I calculate how many "../" I need to get to the root directory from any location in a sub directory?</p>
