0

I am passing multiple parameters in url like

http://website.com/controller/action/para1/para2/para3/para4/para5

Now I have to access para4

How could I access para4 ?

Edit 2 : output of debug($this->request->params)

[
    'plugin' => null,
    'controller' => 'ServiceRequests',
    'action' => 'checkout',
    '_ext' => null,
    'pass' => [
        (int) 0 => '7e441d08-fdb2-4f86-9a36-d15c61a8a4f0',
        (int) 1 => 'b95c0ca1-7782-4621-ad37-cccf697c777c',
        (int) 2 => '3df2d1c5-18c6-4c4b-a3bf-c763ce1b41c7',
        (int) 3 => 'ac1f0acd-b7d2-4d61-b37d-4990e4774392',
        (int) 4 => '1',
        (int) 5 => '338ae9f9-0973-4943-b6e1-c12a7713af89'
    ],
    'isAjax' => false
]
2
  • Depends on the route that you've defined to match that URL. You may want to add that to your question. Commented Jun 25, 2016 at 12:57
  • i haven't added route. I'm expecting solution like $ar[3] or any index value that can be used to access any part of parameters or URL Commented Jun 25, 2016 at 16:21

1 Answer 1

1

At your controller (or wherever this request is handled), do debug($this->request->data) or debug($this->request->query) or debug($this->request->params).

I don't exactly recall which one of those will give you the parameters you want. If none of these show you your request structure which will allow you to understand how to access your parameters do debug($this->request)

When you debug you can see how to access these parameters. They should be an array of arguments so you should be able to access them pretty easily. If instead they appear as one variable separated by '/' you can use php's explode function to add them all in an array, something like:

$data = explode('/', $this->request->data);
Sign up to request clarification or add additional context in comments.

2 Comments

I have added output of debug($this->request->params) how to access pass array elements in view.
got it working by $this->request->params['pass']['3]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.