Can arrays be used to pass multiple variables between PHP functions?

Arrays can be used to pass multiple variables between PHP functions by storing the variables as elements within the array and passing the array as a parameter to the function. This allows for passing multiple values in a structured way and simplifies the code by reducing the number of parameters being passed.

// Using an array to pass multiple variables between PHP functions
function processVariables($data) {
    // Access variables from the array
    $var1 = $data['var1'];
    $var2 = $data['var2'];
    
    // Perform operations using the variables
    // Example: echo the variables
    echo $var1 . ' ' . $var2;
}

// Define the variables and store them in an array
$variables = array(
    'var1' => 'Hello',
    'var2' => 'World'
);

// Call the function and pass the array of variables
processVariables($variables);