How can arrays be used in PHP to handle form data submitted via method=GET?
When form data is submitted via method=GET in PHP, the form input names are passed as key-value pairs in the URL query string. To handle this data efficiently, you can use arrays in PHP to group related form inputs together. This allows you to access and process the form data easily by looping through the array elements.
// Example code snippet to handle form data submitted via method=GET using arrays
if ($_SERVER["REQUEST_METHOD"] == "GET") {
// Access form data using arrays
$username = $_GET['username'];
$password = $_GET['password'];
// Process the form data
echo "Username: " . $username . "<br>";
echo "Password: " . $password . "<br>";
}