<?php
$file_array = array("file.txt","file2.txt","file3.txt","file4.txt","file5.txt");
if (isset($_POST["mycount"])) $mycount = $mycount + 1;
else $mycount = 0;
$filename = $file_array[$mycount];
$handle = fopen($filename, "r");
if(!$handle)
{
echo "Ошибка чтения файла!";
}
else
{
$contents = fread($handle, filesize($filename));
fclose($handle);
}
$newtext = implode("", file($filename));
$newtext = str_replace("\r\n", " ", $newtext);
$str_mass = explode(" ", $newtext);
$i = 0;
while( $i < 100 )
{
$newtext .= $str_mass[$i]."\r\n";
$i++;
}
$newtext = str_replace('.', '', $newtext);
$newtext = str_replace(',', '', $newtext);
$newtext = str_replace(':', '', $newtext);
$newtext = str_replace('"', '', $newtext);
$newtext = str_replace('\'', '', $newtext);
$newtext = str_replace('-', '', $newtext);
$newtext = str_replace('?', '', $newtext);
$newtext = str_replace('!', '', $newtext);
$newtext = str_replace(' ', ' ', $newtext);
$newtext = str_replace(" ", "\r\n", $newtext);
echo "
<html>
<head><title>Example</title></head>
<body>
<form action=\"ifile.php\" method=\"post\">
<table>
<tr>
<td colspan=\"2\">Форма работы с textarea</td>
</tr>
<tr>
<td><textarea rows=\"20\" cols=\"55\">".$contents."</textarea></td>
<td><textarea rows=\"20\" cols=\"55\">".$newtext."</textarea></td>
</tr>
<tr>
<td colspan=\"2\"><input type=\"submit\" value=\"Run script!\"></td>
</tr>
</table>
<input type=\"hidden\" name=\"mycount\" value=".$mycount.">
</form>
</body>
</html>";
?>