title: PHP: Get last directory name from path
body: <p>I am writing one function for getting some different database query. Now things are going well but only need to get last directory name from defined path.</p>
  
  <pre><code>$qa_path=site_root('/learnphp/docs/');
  </code></pre>
  
  <p>I wan to get only <code>docs</code> from above path. Here site_root is nothing but <code>$_SERVER['DOCUMENT_ROOT']</code> So how can I get only <code>docs</code> ?</p>
  
  <p>Thanks</p>