What are the potential pitfalls of using an array to pass parameters to a PHP function instead of individual parameters?

Using an array to pass parameters to a PHP function can make the code less readable and harder to maintain. It can also lead to errors if the array keys are not properly defined or if the function expects a specific order of parameters. To solve this issue, it's better to pass individual parameters to the function to make the code more clear and organized.

// Instead of passing parameters as an array
function myFunction($params) {
    $param1 = $params['param1'];
    $param2 = $params['param2'];
    // Rest of the function logic
}

$params = ['param1' => 'value1', 'param2' => 'value2'];
myFunction($params);

// Pass individual parameters instead
function myFunction($param1, $param2) {
    // Function logic
}

myFunction('value1', 'value2');