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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.