all i want is to display the contains from pageset.txt line by line.
ok i have this code:
$lines = file('pageset.txt');
foreach($lines as $line) {
// do something with $line.
$hh = $line . "<br/>";
echo $hh;
now i want to display it line by line as you see there is
so it means each contains should display line by line and so it must however it doesnt display line by line and the bad thing is it only display one contains from pageset.txt. hope someone here could help, thank you in advance.
You keep overwriting
$hhbefore echoing out the last line.Try this instead:
file_get_contentsto read in the whole file in one go (unsuitable for extremely large files, but still better thanfilein that regard).htmlspecialcharsto escape any HTML in the file so that, in particular, < is shown correctly. Remove if you actually want to include the file's HTML.nl2bris a haxy method of adding<br />to the end of each line. Essentially it's a shorthand forstr_replace(PHP_EOL,"<br />".PHP_EOL,$input).