Is parameter passing by reference an effective way to reduce memory usage in PHP scripts?

Parameter passing by reference in PHP can be an effective way to reduce memory usage in scripts because it allows you to directly manipulate the original variable without creating a copy in memory. This can be particularly useful when working with large arrays or objects, as passing them by reference can prevent unnecessary memory consumption.

// Example of passing a parameter by reference to reduce memory usage
function modifyArray(&$array) {
    for ($i = 0; $i < count($array); $i++) {
        $array[$i] = $array[$i] * 2;
    }
}

$myArray = [1, 2, 3, 4, 5];
modifyArray($myArray);
print_r($myArray);