How can the explode() function be used effectively to split lines in PHP?

The explode() function can be effectively used to split lines in PHP by specifying the delimiter at which the string should be split. For example, if you have a string with multiple lines separated by a newline character "\n", you can use explode("\n", $string) to split the string into an array of lines. This allows you to easily access and manipulate each line separately.

$string = "Line 1\nLine 2\nLine 3";
$lines = explode("\n", $string);

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