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
Try explode('/', '/learnphp/docs/') to split the string into array locations. Then fetch the last location.
explode('/', '/learnphp/docs/')
Here is more info: http://php.net/manual/en/function.explode.php