Sunday, February 1, 2009

How to add a html
tags to newline characters in php - nl2br()

The easiest way to add a HTML break
to all new lines in a string is to use the php nl2br() function. This is really great when you want to restore new lines from a user input by a textarea where user input could get into several lines.



<?php

echo nl2br("line1\n line2");

?>


No comments:

Post a Comment