PHP: Get last directory name from path

后端 未结 8 1875
说谎
说谎 2021-01-11 10:52

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.

$q         


        
8条回答
  •  再見小時候
    2021-01-11 11:24

    you can use this simple snippet:

    $qa_path=site_root('/learnphp/docs/');
    $qa_path = explode("/", $qa_path);
    $qa_path = $qa_path[count($qa_path) - 1];
    

提交回复
热议问题