PHP: Count array items and then remove '../' foreach array item
<p>Okay, a bit hard to explain but what I am trying to do is create a subheader for my site. The sub header will be based on the current URL lets use <code>sub/test/3rdleveldown/blog/post</code> as an example. What I need the subheader to do is, make a seperate link for each level of the url</p>

<p>Example: This would produce:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;a href="../../../../sub"&gt;Sub&lt;/a&gt; &gt;&gt; &lt;a href="../../../test"&gt;Test&lt;/a&gt; &gt;&gt; &lt;a href="../../3rdleveldown"&gt;3rdleveldown&lt;/a&gt; &gt;&gt; &lt;a href="blog"&gt;blog&lt;/a&gt;</code></pre>
</div>
</div>
</p>

<p>This would allow the user to go down URL levels easily.</p>

<p>What I've managed to do is this</p>

<pre><code>&lt;div class="subheader"&gt;
  &lt;?php
  $uri = $_SERVER['REQUEST_URI'];
  $array = explode('/', $uri);
  $count = count($array);
  ?&gt;
  @foreach ($array as $sub)
    &lt;a href="NOW HERE I NEED TO ENTER the ../ based on how far down the link is in the array {{ $sub }}"&gt;{{ $sub }}&lt;/a&gt; &gt;&gt;
  @endforeach
&lt;/div&gt;
</code></pre>

<p>Can anybody help me get the <code>../</code> for each level down?</p>