Have you ever try to replace '\n' to '<br>' by php
You should write this str_replace("\n", "<br>", $string);
If you write this str_replace('\n', "<br>", $string);
That will go bad because "\n" is actually 0x0A but '\n' is just 0x5C6E!
Have you ever try to replace '\n' to '<br>' by php
You should write this str_replace("\n", "<br>", $string);
If you write this str_replace('\n', "<br>", $string);
That will go bad because "\n" is actually 0x0A but '\n' is just 0x5C6E!
For further actions, you may consider blocking this person and/or reporting abuse
Andrew Elans -
Antonio Silva -
Ahmed Salem -
Rodrigo Antunes -
Top comments (4)
PHP also has the
nl2br
function, because reasons.I am forgetting to write about nl2br
This method insert br tag in front of new line code
So if you don't want new line code live, You must make your original code.
But usually you can use nl2br
PHP_EOL
constant will adept to the system being used on.Thank you for your answers, guys