0

textarea は、テキストが終了ウィンドウに到達すると自動的に新しい行を作成します。テキストを *.txt me 行に保存します。表示されているフォームでテキストを保存するにはどうすればよいですか? phpの場合?

enter code here
if(isset($_POST['submit'])){
//narredi file
$ourFileName = "baza/$file1.txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
//konec naredi

//shrani besedilo
$area=$_REQUEST['area'];

        //$area12 = explode(" ", $area);
        //$area12 = str_replace('\n', '<br />', $area);

$text = trim($_POST['area']); // 最後の \n または空白文字を削除します $text = nl2br($text);

$loadcontent = "baza/$file1.txt";
$fd=fopen("$loadcontent", "w+") or die("can't open file");
fwrite($fd,$text);
fclose($fd);
$file_contents=file_get_contents("baza/$file1.txt");



<textarea name="area" id="Data" wrap="on" cols=100 rows=5 >
test
testttt
testt</textarea>
<br>
<input type="submit" name="submit"  value="Objavi" />

テキストエリアのサイズ (css) を定義しました。表示されているウィンドウよりも長いテキストを書き込むと、実際には 1 行で表示される新しい行が作成されます。2行以上欲しい…。

4

1 に答える 1

0

私にとってはとても良いです

$vrst = explode("\n", $loadcontent1);
$vrst1 = count($vrst);                        
$a = 0;
StartOfLoop: 
$lines = array_slice(explode("\n", $loadcontent1), "$a", 1);
$stevil = strlen($loadcontent1); 
$stevilo = $stevil / 88;
$stringpred = implode("\n", $lines);
$trimmed1 = strlen($stringpred);
        $vrstic = $trimmed1/88+1;
if (88 > $trimmed1) goto pogojzavec;
 foreach ($lines as $key => $value)
{
$a=0;
do
  {
$lines[$key] = substr(trim($value), "$a", "88+$a");
$string = implode("\n", $lines);
$stringg11 = $string;
$stringg2 = "$stringg2\n$stringg11";
$a =$a +88;
  }
while ($a<=$trimmed1);
        }
goto preskok;
pogojzavec:
 foreach ($lines as $key => $value)
{
   $lines[$key] = substr(trim($value), 0, 88);
}
$string = implode("\n", $lines);
$stringg11 = $string;
$stringg2 = "$stringg2\n$stringg11";
preskok:
      $a = $a + 1;
  if($a < $vrst1)  goto StartOfLoop;
于 2013-03-23T22:41:43.933 に答える