title: PHP - remove last part from URL
body: <p>Good day to all!</p>
  
  <p>I need to grab article's URL and modify it by deleting the last part of it (moving one level up).</p>
  
  <p>Grabbing the current URL with Wordpress function <code>&lt;?php echo get_permalink( $post-&gt;ID ); ?&gt;</code></p>
  
  <p>Example of use. My current article's URL:</p>
  
  <pre><code>http://example.com/apples/dogs/coffee
  </code></pre>
  
  <p>Delete the last part of URL so it will be:</p>
  
  <pre><code>http://example.com/apples/dogs
  </code></pre>
  
  <p>(And with no slash at the end)</p>
  
  <p>So this will return the current Wordpress URL:</p>
  
  <pre><code>&lt;a href="&lt;?php echo get_permalink( $post-&gt;ID ); ?&gt;"&gt;Text&lt;/a&gt;
  </code></pre>
  
  <p>but how can I delete the last part of it?</p>
  
  <p>Thanks in advance!</p>