How can PHP be used to automatically wrap text input in a form before saving it to a database?

When accepting text input from a form in PHP, it's important to sanitize and format the data before saving it to a database to prevent security vulnerabilities and ensure consistency. One way to automatically wrap text input is to use the PHP function `wordwrap()` which breaks a string into lines of a specified length. By applying `wordwrap()` to the text input before saving it to the database, you can ensure that long lines of text are properly formatted.

// Assuming $text_input contains the text input from the form
$wrapped_text = wordwrap($text_input, 80, "\n", true);

// Save $wrapped_text to the database
// Example SQL query:
// $sql = "INSERT INTO table_name (text_column) VALUES ('$wrapped_text')";
// mysqli_query($connection, $sql);