Name

basename

Synopsis

string basename(string path[, string suffix])

Returns the filename component from the full path path. If the file’s name ends in suffix, that string is removed from the name. For example:

$path = "/usr/local/httpd/index.html";
echo(basename($path)); // index.html
echo(basename($path, '.html')); // index

Get Programming PHP, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.