Wierd indentationans are occuring when I read a text file into the text area of a form. I'm attempting to write a CMS for a site WITHOUT using a db. Although I have access to a DB, I really want to crack this without resorting to the usual method - I do think it's a bit of an overkill using up server resources if only simple page editing is required.
My code in the form looks like this:
<textarea name="performances_1" cols="43" rows="10">
<?
$fp = fopen("/text/text_1.txt","r");
while (!feof($fp))
{
$text_1 = fgets($fp,100);
echo $text_1; ?>
}
fclose($fp);
?>
</textarea>
When outputed in browser, test text looks similar to:
==============================
hello. this is a test
==============================
even though if I view the actual text file directly in the browser, it looks fine.
Has anyone seen this problem before?
BTW, my php script to write to the text file is:
<?
$fp = fopen("/text/text_1.txt","w");
flock($fp,2);
$text_1 = trim($text_1);
fwrite($fp, $text_1);
flock($fp,3);
echo "text updated";
?>