What is the significance of using references when passing arrays to functions in PHP?

When passing arrays to functions in PHP, it is important to use references to avoid creating unnecessary copies of the array. This can improve performance and save memory, especially when dealing with large arrays. By passing arrays by reference, any changes made to the array within the function will affect the original array outside of the function as well.

// Passing array by reference to a function
function modifyArray(&$arr) {
    $arr[] = "new element";
}

// Original array
$array = [1, 2, 3];

// Call the function with the array passed by reference
modifyArray($array);

// Output the modified array
print_r($array);