I'm posting the following values to a Symfony2 web page:
code=-1&tracking=SRG12891283&description=Error&code=0&tracking=SRG19991283&description=Label Printed.
Note the duplicates - there could be any number of code/tracking/description 'pairs'.
In Symfony, when I do the following, it only outputs the last set of values:
foreach($request->request->all() as $key => $val){
$this->m_logger->debug($key . ' - ' .$val);
}
i.e.
code = 0 tracking = SRG19991283 desription = Label Printed.
I'm assuming this is because the request class stores the parameters in key/value pairs and so subsequent params are simply overwriting the previous ones.
Any idea how I can access all of these values?
If you use "array-like" syntax in your parameters, Symfony should do what you want.
For example, consider a querystring of ?code[0]=a&code[1]=b&code[2]=c.
$request->query->get('code'); in Symfony would return an array like this:
[
0 => "a",
1 => "b",
2 => "c",
]
... which I think is what you want? (Albeit this is a simpler example.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With