How can PHP handle multiple form inputs as an array for easy processing and database storage?
When dealing with multiple form inputs in PHP, you can handle them as an array by naming the form inputs with square brackets in the HTML form. This way, PHP will automatically treat them as an array when processing the form data. You can then iterate over the array in PHP to access and store the values in a database.
<form method="post" action="process_form.php">
<input type="text" name="input[]" />
<input type="text" name="input[]" />
<input type="text" name="input[]" />
<input type="submit" value="Submit" />
</form>
```
```php
// process_form.php
// Assuming a database connection is established
if(isset($_POST['input'])) {
foreach($_POST['input'] as $value) {
// Process and store each value in the database
$sql = "INSERT INTO table_name (column_name) VALUES ('$value')";
mysqli_query($conn, $sql);
}
}