如何更换新线

$t = '"Confidence isn\'t gained over time and practice. Confidence is gained when you realize you choose your own path, you choose to fall, you choose not to fall.

If you are afraid to fall you fall because you are afraid. Everything is choice." - Daniel ILabaca';
$order   = array("
", "
", "");
$text = str_replace($order, '<br/>', $t);

But in the database is still the new line.

Before inserting I do htmlspecialchars(addslashes(trim($text)))

Why don't you have a go with the nl2br() function? Try this:

$text = nl2br($t);

Instead of the following two rows that is:

$order   = array("
", "
", "");
$text = str_replace($order, '<br/>', $t);

If you don't want any linebreaks at all and don't want to have them converted to HTML <br > have a look at this here: Remove all the line breaks from the html source

You should use PHP built-in method nl2br()

nl2br — Inserts HTML line breaks before all newlines in a string 

Example

<?php
    echo nl2br("Welcome
This is my HTML document", false);
?>

Output

Welcome<br>
This is my HTML document

Instead of the $order and str_replace bits, simply try $text = nl2br($t);

While saving data in DB it only needs to be escaped to prevent SQL injection. No need to execute htmlspecialchars, nl2br, addslashes etc. You save the user data as it is. But make sure its safe. You should use htmlentities, nl2br, addslashes etc functions while displaying this data at the presentation layer.