Reputation: 37
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
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
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