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
Provided answer doesn't work if your string contains the file at the end, like :
basename('/home/mypath/test.zip');
gives
test.zip
So if your string contains the file, don't forget to dirname it first
basename(dirname('/home/mypath/test.zip'));
mypath