0
I would like to take all the values of a certain key of a request.
Ex Request:
nnmSoftware=7-Zip&idSoftware=1181&nmLocal=Empresa&idRede=1&nmSoftware=account-plugin-aim&idSoftware=1&nmLocal=Empresa&idRede=1, referer: http://localhost/app_dev.php/report/software/inventoried
But when I try to take it $software = $request->get('idSoftware');
returns only idSoftware = 1
.
How would I get them all? idSoftware = 1, 1181
Who
$request
is that it? Wouldn’t it be$_REQUEST['key']
?– gmsantos
exactly, gmsantos. But even using $_REQUEST['idSoftware'] it brings only 1 idSoftware
– Bruno Menezes
I can’t test at the moment, but I believe I can add it to an array: array_push($array, $request->get('idSoftware'))
– Luis Henrique
Are you using some framework?
– Wallace Maxters
Try
$var = $_SERVER['QUERY_STRING'];

parse_str($var, $result); print_r($result);
– Wallace Maxters
@Luishenrique using push array_returns empty.
– Bruno Menezes
@Wallacemaxters, I use symfony.
– Bruno Menezes
@Brunomenezes notice your query, you call
idSoftware
twice! So the value is 1: nnmSoftware=7-Zip& idSoftware=1181 &nmLocal=Company&idrede=1&nmSoftware=Account-plugin-Aim& idSoftware=1 &nmLocal=Empresa&idrede=1. Doing this via GET is not possible, only via POST.– gmsantos
@gmsantos. I need to take these two values. In some situations I will have 200 Idsoftwares
– Bruno Menezes
I’m running out of time to answer now, but basically you need the method to be sent via POST and have
[]
in the name ofinput
:<input name="idSoftware[]">
. ThusidSoftware
will be an array.– gmsantos
I agree with you and suggest the use of POST. However, selecting the array before going through get would not solve the @gmsantos problem?
– Luis Henrique
@gmsantos Perfect. Thank you very much, it was just that.
– Bruno Menezes