如何获取当前目录的名称 - 而不是整个路径? [重复]

Possible Duplicate:
How to get the last dir from a path in a string

I'm using getcwd() to return something like this: home/abc123/public_html/blah/myDir

How can I modify this string to simply return myDir?

http://php.net/manual/en/function.basename.php

Either use basename:

print basename("home/abc123/public_html/blah/myDir");
//Output: myDir

Or strpos and substr:

$fullPath = "home/abc123/public_html/blah/myDir";
print substr($fullPath, strrpos($fullPath, "/") + 1);
//Output: myDir