How can the issue of missing line breaks in the textarea output be resolved in the given PHP code snippet?

The issue of missing line breaks in the textarea output can be resolved by using the PHP nl2br() function to convert newline characters to HTML line breaks. This function will ensure that line breaks are properly displayed in the output.

<?php
if(isset($_POST['submit'])){
    $text = $_POST['text'];
    echo nl2br($text);
}
?>

<form method="post">
    <textarea name="text"></textarea>
    <input type="submit" name="submit" value="Submit">
</form>