title: How to remove the first & last slash from a url if it's exists?
body: <p>I use parse_url() to get the path of a url but i want to remove the first slash &amp; the last if it's exists.</p>
  
  <p>Example: </p>
  
  <pre><code>"/posts/funny-dog/" -&gt; "posts/funny-dog"
  "/" -&gt; "" // Because http://www.google.com/ path is a slash
  "/categories/politic" -&gt; "categories/politics"
  </code></pre>
  
  <p>Thanks</p>