I have a query string being sent to a php file as so: participants[]=111111111,22222222,333333333 etc….
If I remove the [] it functions fine, however, if I leave it in it ignores the array for each. How can I make PHP iterate through the comma seperated values with [] on the variable name? I tried explode which also failed unless I removed the []. I need to create a for each statement for the number of values returned for that var.
I have the following PHP code:
$participants = $_REQUEST["participants"];
foreach($participants as $i=>$value) {
if($value > 1) {
// define each variable
$id = $_REQUEST['participants'][$i];
print "$id<br />";
}
}
I suggest using explode() in your code.
Since you can’t remove the brackets in your query string, you may test the following code:
The output now is:
111111111
22222222
333333333