How can PHP's explode() function be utilized to separate data based on line breaks?

To separate data based on line breaks using PHP's explode() function, you can first read the data from a file or a string, then use explode() with the newline character "\n" as the delimiter. This will split the data into an array where each element corresponds to a line of the original data.

// Read data from a file or a string
$data = "Line 1\nLine 2\nLine 3";

// Separate data based on line breaks
$lines = explode("\n", $data);

// Output each line
foreach ($lines as $line) {
    echo $line . "<br>";
}