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
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Add Text Watermark to Image in PHP?
- PHP implode() Function Example Tutorial
- PHP Subtract Month from Date Example
- How to Upgrade PHP Version from 7.4 to 8 in Ubuntu?
- PHP Curl Delete Request Example Code
- PHP Curl Request with Certificate (cert pem file option) Example
- Laravel PHP json_decode without quotes Example
- How to Remove Multiple Keys from PHP Array?
- How to Find Day Name from Specific Date in PHP?
- How to Remove Null Values from Array in PHP?