2012-11-06 46 views
0

textarea在文本到達結束窗口時自動創建一個新行。 將* .txt文本保存在一行中。 如何以我看到的形式保存文本? 如果在PHP?php textarea保存如

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" /> 

我已經定義textarea的大小(CSS),當我寫的文字可視窗口不再那麼它建立在事實一行可見新線。我想要兩個線或更多....

+1

EM它是什麼,你想幹什麼? –

+0

我已經定義了textarea大小(css),並且當我將文本寫入更長的可見窗口時,它實際上會創建一條可見的新行。我想要兩行或更多.... –

回答

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;