0

当文本到达结束窗口时,textarea 会自动换行。将文本保存在 *.txt 我存储在一行中。如何以我看到的形式保存文本?如果在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),当我写更长的可见窗口的文本时,它会创建一个可见的新行,实际上是一行。我想要两行或更多....

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 回答