Echo HTML line by line. Possible or not?
Posted: Mon Apr 14, 2008 6:09 am
Hello,
I've been using the following code to echo lines from a text file before. Now I've tried to use the same thing to echo certain parts of a html page. Instead of converting the text to html, it simply displays the html source as text.
For example, it would echo lines 120 and 121, but instead of displaying the html correctly, it simply echos the html source code.
Any ideas on what I can do to make this script handle the html as html rather than text?
Thanks in advance.
I've been using the following code to echo lines from a text file before. Now I've tried to use the same thing to echo certain parts of a html page. Instead of converting the text to html, it simply displays the html source as text.
Code: Select all
<?php
// file() loads the contents of file.txt into an array, $lines
// each line in the file becomes a seperate element of the array.
$lines = array_reverse( file( '../pagetest.html' ) );
// we can also access each line of the file seperately
echo htmlspecialchars($lines[120]) . '<br />';
echo htmlspecialchars($lines[121]) . '<br />';Any ideas on what I can do to make this script handle the html as html rather than text?
Thanks in advance.