How can PHP be used to accurately count the number of line breaks in a text input?

To accurately count the number of line breaks in a text input using PHP, you can use the `substr_count()` function to count the occurrences of the newline character `\n`. This function will return the number of times the newline character appears in the input text, giving you an accurate count of the line breaks.

<?php
$text = $_POST['text']; // Assuming the text input is submitted via POST method
$line_breaks = substr_count($text, "\n");
echo "Number of line breaks: " . $line_breaks;
?>