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 will return only the last part of an URL

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

If your URL has more stuff to it and what you need is the dir name containing the file you can use it with dirname() like this:

$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:


How to break down an URL:
* Using basename

Table Of Contents
2 Arrays
4 Types
10 Cookies
14 JSON
15 SOAP
17 cURL
19 XML
21 Traits
35 UTF-8
36 URLs
38 PHPDoc
41 Loops
44 Closur
72 YAML
77 Cache
78 Streams
81 PDO
82 SQLite3
83 Sockets
87 MongoDB
93 IMAP
94 Redis
95 Imagick
102 APCu
107 How to break down an URL
108 PSR