Using basename

suggest change

basename(): Given a string containing the path to a file or directory, this function will return the trailing name component.

This function returns only the last part of a URL:

$url = "http://example.com/project/controller/action/param1/param2";
$parts = basename($url);
// Output: param2

If the URL ends in a filename and you need the directory that contains it, combine basename() with dirname():

$url = "http://example.com/project/controller/action/param1/param2/index.php";
$parts = basename(dirname($url));
// Output: param2

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents