How can the return statement impact the output of a function that uses the range() function in PHP?

When using the range() function in PHP, the return statement within a function can impact the output by terminating the function prematurely and returning a value before the range is fully processed. To ensure that the full range is generated and returned, the return statement should be placed outside of any loops or conditional statements that may interrupt the range generation.

function generateRange($start, $end) {
    $result = [];
    
    for ($i = $start; $i <= $end; $i++) {
        $result[] = $i;
    }
    
    return $result; // Return statement placed outside of the loop
}

// Example usage
$numbers = generateRange(1, 5);
print_r($numbers); // Output: Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )