How can the output from a stream be divided into lines in PHP without explicit line breaks?

When reading from a stream in PHP, the output may not have explicit line breaks, making it difficult to divide the content into lines. One way to solve this issue is by using the `fgets()` function to read the stream line by line until the end of the stream is reached. This function reads a line from the stream and stops when it encounters a newline character. By repeatedly calling `fgets()` in a loop, you can effectively divide the stream output into lines.

$stream = fopen('example.txt', 'r');
if ($stream) {
    while (($line = fgets($stream)) !== false) {
        // Process each line here
        echo $line . PHP_EOL;
    }
    fclose($stream);
}