I have two multiple selects declared as:
<form method="post">
<input type="text" name="vcgame[]" id="vcgame_1" value="">
<select name="vccoun[][]" id="vccoun_5" multiple="multiple">
<option value="1">West Indies</option>
<option value="2" selected="selected">India</option>
<option value="3" selected="selected">Australia</option>
</select>
<input type="text" name="vcgame[]" id="vcgame_2" value="">
<select name="vccoun[][]" id="vccoun_9" multiple="multiple">
<option value="4">Italy</option>
<option value="5" selected="selected">Germany</option>
</select>
</form>
I want to catch the values in PHP, like this
$game_list= $_POST['vcgame'];
$country_list= $_POST['vccoun'];
$game_country= array();
foreach($game_list as $key=>$val)
{
$game_country[$key]= $country_list[$key];
}
But the values come like this (with print_r
on the $_POST
):
[vcgame] => Array
(
[0] => cricket
[1] => football
)
[vccoun] => Array
(
[0] => Array
(
[0] => 2
)
[1] => Array
(
[0] => 3
)
[2] => Array
(
[0] => 5
)
)
instead of:
[vcgame] => Array
(
[0] => cricket
[1] => football
)
[vccoun] => Array
(
[0] => Array
(
[0] => 2
[1] => 3
)
[1] => Array
(
[0] => 5
)
)
How can this be achieved? Can anyone help? Thanks in advance.