title: Get the value of a URL after the last slash
body: <p>Say I have the following URL values:</p>
  
  <pre><code>http://website.com/tagged/news/
  http://website.com/tagged/news
  http://www.website.com/tagged/news/
  http://www.website.com/tagged/news
  </code></pre>
  
  <p>I'd like to have a PHP function to get news in this example. So I want the value after the last slash if it isn't blank and if that value is blank, then I'd like to get the value before that slash.</p>
  
  <p>I found this post:
  <a href="https://stackoverflow.com/questions/5921075/get-last-word-from-url-after-a-slash-in-php">Get last word from URL after a slash in PHP</a></p>
  
  <p>But I'd like to be really sure just in case someone types a slash at the end of the URL.</p>