In what scenarios is it recommended to use references in PHP functions for array manipulation?

When working with large arrays in PHP functions, passing them by value can lead to performance issues due to memory consumption. In such scenarios, it is recommended to use references in PHP functions for array manipulation. By passing arrays by reference, you can modify the original array directly without creating a copy, resulting in better performance.

// Using references in PHP functions for array manipulation
function manipulateArray(&$array) {
    // Manipulate the array directly
    array_push($array, "new element");
}

// Original array
$originalArray = ["element1", "element2"];

// Call the function with the original array passed by reference
manipulateArray($originalArray);

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