What best practices should be followed when passing arrays to PHP functions to avoid errors or unexpected behavior?

When passing arrays to PHP functions, it is important to ensure that the function can handle arrays correctly to avoid errors or unexpected behavior. One common mistake is assuming that the input will always be an array, leading to issues if a different data type is passed. To avoid this, it is recommended to check if the input is an array before processing it within the function.

function processArray($inputArray) {
    if (!is_array($inputArray)) {
        return "Input must be an array";
    }

    // Process the array here
}