PHP nl2br() Function Example Tutorial

This article will provide some of the most important example nl2br in php. Here you will learn php nl2br example. this example will help you php nl2br() function example. you’ll learn php convert nl2br. Let’s see bellow example php nl2br replace n to br.

nl2br() function will replace n into newline. so let’s see syntax and example

Syntax:

nl2br() function will take two argument. first as string and it’s required. second as A boolean value that indicates whether or not to use xhtml compatible line breaks and it’s optional.

nl2br(string,xhtml)

Example:

index.php

<?php

$desc = "Line one n Line two n Line three n Live four n Line five ";

echo nl2br($desc);

Output

Line one

Line two

Line three

Live four

Line five

.medrectangle-4-multi-155{border:none!important;display:block!important;float:none;line-height:0;margin-bottom:15px!important;margin-left:0!important;margin-right:0!important;margin-top:15px!important;max-width:100%!important;min-height:250px;min-width:300px;padding:0;text-align:center!important}

I hope it can help you…

1 thought on “PHP nl2br() Function Example Tutorial”

Leave a Comment