explode(): Returns an array of strings, each of which is a substring of string formed by splitting it on boundaries formed by the string delimiter.
This function is pretty much straight forward.
$url = "http://example.com/project/controller/action/param1/param2"; $parts = explode('/', $url); Array (  => http:  =>  => example.com  => project  => controller  => action  => param1  => param2 )
You can retrieve the last part of the URL by doing this:
$last = end($parts); // Output: param2
You can also navigate inside the array by using sizeof() in combination with a math operator like this:
echo $parts[sizeof($parts)-2]; // Output: param1