Getting params from url

how can i get the params form a url , example :

$url = "localhost/controller/action/param1/param2"; // a manual url i need to get params
$this->dispatcher->getParams(); // returns all in array ( need somthing like this )

Use named params in route, and then in function in action you have those params.