What is best practice for sending multidimensional arrays from an HTML form using either GET or POST? I couldn't find anything from Googling..
I've done things like this (name="array[]"
) when working with check-boxes and things, but what if I want my array to be associative/multidimensional? I wrote the following to test my theory and it works fine locally but is it reliable/best practice? Can I expect this to work when I upload to server?
<?php
if(count($_GET) > 0){
echo "<pre>";
echo var_dump($_GET);
echo "</pre>";
}else{
?>
<form method="GET" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="name" value="bob dole" />
<input type="hidden" value="myarr" name="arr[name]" />
<input type="hidden" value="green" name="arr[color]" />
<input type="submit" value="go" />
</form>
<?php
}
?>