Hi all. Can anyone help me out here?
A script like this...
echo "<form action='processform.php' method='POST'>\n";
echo "<select name='name[sphere]'>\n";
echo "<option value='colour[] '>Select One</option>\n";
echo "<option value='colour[red]'>1</option>\n";
echo "<option value='colour[green]'>2</option>\n";
echo "<option value='colour[blue]'>3</option>\n";
echo "</select><br>\n";
echo "<select name='name[cube]'>\n";
echo "<option value='colour[]'>Select One</option>\n";
echo "<option value='colour[red]'>1</option>\n";
echo "<option value='colour[green]'>2</option>\n";
echo "<option value='colour[blue]'>3</option>\n";
echo "</select><br>\n";
echo "<input type='submit' value = 'go'>\n";
echo "</form>\n";
can produce an array like this...
$_POST:
Array
(
[name] => Array
(
[sphere] => colour[red]
[cube] => colour[green]
)
)
but I guess I'm after an array more like this...
$_POST:
Array
(
[0] => Array
(
[primitive] => sphere
[colour] => red
)
[1] => Array
(
[primitive] => sphere
[colour] => green
)
)
I suspect that this can be done by simply revising the form, without
the need for any additional post-processing.
Going one step further, I'd really like values to passed to the array
ONLY if a value other than the default is selected, but I guess I can
just pass all the values and then use a loop to filter the results.
Any thoughts?