output text without format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
weixin268
Forum Newbie
Posts: 15
Joined: Mon Feb 17, 2014 12:53 am

output text without format

Post by weixin268 »

Hello!

have a php page to read text file, but without text format, how to fix it? Thanks!

Original Text File format as shown on below: namelist.txt
https://drive.google.com/file/d/0B0uU4S ... sp=sharing


php displayed format:
https://drive.google.com/file/d/0B0uU4S ... sp=sharing

code page:

Code: Select all

<?php 
$file_handle = fopen("d:/data/namelist.txt", "r");

while (!feof($file_handle)) {

$line_of_text = fgets($file_handle);
print $line_of_text . "<BR>";

}

fclose($file_handle);
?>
weixin268
Forum Newbie
Posts: 15
Joined: Mon Feb 17, 2014 12:53 am

Re: output text without format

Post by weixin268 »

solved as shown on below:

<?php
$file_handle = fopen("d:/data/namelist.txt", "r");
[text][/text]echo '<pr>';
while (!feof($file_handle)) {

$line_of_text = fgets($file_handle);
print $line_of_text . "";

}
echo '</pr>';
fclose($file_handle);
?>
Post Reply