Let’s say I wanna pass a bunch of parameters to a url like:
http://localhost/my_app/my_controller/index/param1:1/param2:2/param3:3/param4:4
etc…
But my url is built using the url method of the Html Helper like so:
$this->Html->url(array(
'controller' => 'my_controller',
'action' => 'index',
'param1' => 1,
'param2' => 2,
'param3' => 3,
'param4' => 4
));
I tried to build my params into in array like this and pass it to my url like:
$my_params = array(
'param1' => 1,
'param2' => 2,
'param3' => 3,
'param4' => 4
);
$this->Html->url(array(
'controller' => 'my_controller',
'action' => 'index',
$my_params
));
But that doesn’t work. Any idea how I can do this please?
Thank you
What you intend to do does not work, because you simply add $my_params to the array when you instead should merge the $my_params array with array_merge.
I hope it helps 🙂