Skip to content
Advertisement

nl2br function producing whitespace after newline

The following code produces a whitespace after each newline and I don’t know why. Please help, how can I make the same functionality without adding whitespaces?

JavaScript

Advertisement

Answer

I did the test and I didn’t notice any whitespace after the use of the nl2br() function.

JavaScript

Output

JavaScript

It is worth noting that this function preserves the newlines.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement