PHP Questions Home

Categories

Arrays
Files
Forms
Functions
Images
MySQL
Numbers
Others
Strings
Website


PHP Functions

PHP Functions


More PHP

Top Questions
Ask a Question

How do I convert newlines to HTML line break tags?


To do this use the nl2br function - just pass it the string that contains the newlines and it'll do the rest for you, e.g.

$infowithbrs = nl2br("this\nhas\nline\nbreaks");

echo "$infowithbrs";

More strings PHP Questions

How do I make sure a string is a certain length?
What is the difference between print and echo?
How do I find the last occurrence of a character in a string?
How do I turn a string into an array?
How do I remove space from the start of a PHP string?