First, i have searched on this site for awhile. Basically, when i click save, it adds a carriage return before AND after the line. How do i fix it? Basically, I want to be able to open a text file in a text box, and then save it to the same text file.
Please help me..
Here is my code:
<head>
<title>Text Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<?php
if ($save) {
$fp = fopen("./test.txt", "w");
fwrite($fp, $textfield);
fclose($fp);
}
if (file_exists ("./test.txt"))
{
$arr = file("./test.txt");
$temp;
foreach ($arr as $key => $value)
{
$temp .= $value;
}
}
?>
<form name="hello" method="post" action="<?php echo $PHP_SELF ?>" >
<textarea name="textfield" cols="150" rows="40">
<?php
echo $temp;
?>
</textarea>
</p>
<p>
<input type="submit" value="Save It" name="save">
</p>
</form>
</body>