Store form data in an array in PHP
Description
The following code shows how to store form data in an array.
Example
//from w ww . ja v a 2s. com
//index.php
<?php
if (isset($_POST['submit']))
{
echo "You like the following languages:<br />";
foreach($_POST['languages'] AS $language) echo "$language<br />";
}
?>
<form action="index.php" method="post">
Check all that apply):
<input type="checkbox" name="languages[]" value="csharp" />C#<br />
<input type="checkbox" name="languages[]" value="jscript" />JavaScript<br />
<input type="checkbox" name="languages[]" value="perl" />Perl<br />
<input type="checkbox" name="languages[]" value="php" />PHP<br />
<input type="submit" name="submit" value="Go!" />
</form>
The code above generates the following result.