Read Data from File with Proper New Line

Read Data from File with proper New Line :

That’s definitely the string written to the file, but what happened to that line break? The newline character means nothing to a Web browser, which renders only HTML. Luckily, the PHP development team had great forethought and created the nl2br() function (newline-to-break; get it?).

<?php
$filename = “e:/ashu.txt”;
$myfile = fopen($filename, “r”) or
die(“Unable to open file”);
                                                      $showfile = fread($myfile, filesize($filename));
                                                      $showfile = “<br>nl2br($showfile)<br/>”;
                                                      $msg = “The file contents are <p>$showfile</p>”;
                                                      ?>
                                                      <?=$msg?>

                                             

                                                  

About the author

Being the CEO and Founder of ClecoTech International, Mr. Ashish Prajapati is dedicated towards his aim of mentoring young startups into a full-fledged businesses. He is helping startups from America, Europe, India, and various other countries through proper guidance and the use of latest technologies to develop their innovation and ideas into definite realities.

Leave a Reply

Your email address will not be published.