Hi,
I have an array that looks like this:
sourceid = [[0] => 10586, [1] => 10589, [2] => 10605]
I want to attach this array as url parameters such that my url looks like:
/page/text?sourceid = 10586 & sourceid = 10589 & sourceid = 10605
Later I want to recover these sourceid using $_GET['sourceid] in a different function.
As long as I was attaching a single parameter, I could use the GET function to get the value of the sourceid from url. Now with an array of values, I dont know how to do it.
So far I have tried:
$query = http_build_query(['sourceid' => $sourceid]);
$url = Url::fromRoute('heritage_ui.addpage', ['textid' => $textid]);
$url->setOption('query', [
$query,
]);
But it does not seem to do the job.
Thanks for your help.
Comments
I don't know the way to
I don't know the way to create a query string which contains pairs with the same keys.
But I think that you can pass your original array.
See the example:
Then you can get array with source ids with the code like this:
or in this way:
Ok, thanks.
Ok, thanks.
Passing multiple arguments