PHP: Get last directory name from path

后端 未结 8 1874
说谎
说谎 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:49

    Try explode('/', '/learnphp/docs/') to split the string into array locations. Then fetch the last location.

    Here is more info: http://php.net/manual/en/function.explode.php

    0 讨论(0)
  • 2021-01-11 11:49

    This will help you

    $qa_path=site_root('/learnphp/docs/');
    $q_path = explode ("/", $qa_path);
    $lastV =  end($q_path);
    
    0 讨论(0)
提交回复
热议问题