How do I get the carriage returns in a text file to show up in an html ducument.
Essentially I am writting a text file with a .php extension on it and using the require function to then echo it into an html ducument for online rendering.
The original text document has paragraphs in it- however when it is echoed in html document all the spaces between the paragraphs are lost?
Does any one know how to keep the formating intact?
thanks in advance,
t-
loss of formating from echo to html
Moderator: General Moderators
Instead of "requiring" the file use fopen() and fread() to grab its contents into a string variable, then do a string replace for "\n" and possibly "\r" to "<br />".
Look in the function listings at php.net for both fread and fopen and you should be able to grab most of the code. I'd just write it here, but I'm lazy.
Look in the function listings at php.net for both fread and fopen and you should be able to grab most of the code. I'd just write it here, but I'm lazy.
thanks dude!!
thanks dude!!
I'm in the process of trying this below???
<?php
echo ereg_replace('\r','<br>',$copy);
$CallFunction=WriteToFile
("<tr><td align=\"center\" class=\"title\">".$title."</td></tr>
<tr><td bgcolor=\"#0C2450\"><img src=\"images/cleardot.gif\" height=\"15\"></td></tr>
<tr><td>
<table bgcolor=\"#0C2450\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\">
<tr align=\"center\"><td align=\"left\" width=\"500\" class=\"content\">"
.$copy."
</td></tr>"
);
function WriteToFile($centerCopy){
$TheFile="defaultCopy.php";
$Open=fopen($TheFile, "w+");
fwrite ($Open, "$centerCopy\n");
fclose ($Open);
}
?>
I'm in the process of trying this below???
<?php
echo ereg_replace('\r','<br>',$copy);
$CallFunction=WriteToFile
("<tr><td align=\"center\" class=\"title\">".$title."</td></tr>
<tr><td bgcolor=\"#0C2450\"><img src=\"images/cleardot.gif\" height=\"15\"></td></tr>
<tr><td>
<table bgcolor=\"#0C2450\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" width=\"500\">
<tr align=\"center\"><td align=\"left\" width=\"500\" class=\"content\">"
.$copy."
</td></tr>"
);
function WriteToFile($centerCopy){
$TheFile="defaultCopy.php";
$Open=fopen($TheFile, "w+");
fwrite ($Open, "$centerCopy\n");
fclose ($Open);
}
?>