noob
noob

Reputation: 37

URL parsing for magento

I have following url http://dev.test.com/index.php/socialcoupon/index/deletecoupon/id/28

I need to extract the last digit 28 and put it inside a variable named $id in php. How do I do that?

Thanks

Upvotes: 0

Views: 972

Answers (2)

Girish Hosamani
Girish Hosamani

Reputation: 1203

$id = $this->getRequest()->getParam('id');

write this in your deletecoupon function.

You will get the value in $id

You may also use the getParams method to grab an array of parameters

$data = $this->getRequest()->getParams();

For more check this : How to get a url parameter in Magento controller?

Cheers :-)

Upvotes: 1

Hardik Shah
Hardik Shah

Reputation: 286

If you want to access it in controller action then you can use it like below.

$data = $this->getRequest()->getParam('id');

Upvotes: 0

Related Questions