我知道在这个论坛和其他论坛中有多个这样的例子,我已经尝试了所有这些,但是无法工作。 我有一个写入php文件的php脚本,它被加载到php脚本中。
我的目的是在人们按下“输入”
后将自动br标签放入php-post<?php
if ( isset( $_POST[ 'submit' ] ) ) {
$com = $_POST['txt'];
If ($com === "") {
echo "<font color=red><b>You must write something to post!</font></b>";
die;
}
$time = gmdate("M d Y H:i:s",time()+(2*60*60));
$com = $_POST['txt'];
$count = strlen($com);
$com = stripslashes($com);
$breaks = array("<br />","<br>","<br/>");
$com = str_ireplace($breaks, "\r\n", $com);
$fp = $file = fopen( "NAME_OF_POST.php", "a");
Multiple fwrites follows.....
Multiple fwrites follows.....
rewind($fp);
fclose($fp);
echo '<script type="text/javascript">window.location ="";</script>';
}
?>
并加载到:
<textarea name="txt" id="area" class="typo_vind" placeholder="......" tabindex="1"></textarea>
任何人都知道如何让enter中的换行符替换为br-tags?
提前,比你:)!
答案 0 :(得分:3)
嗯,php有一个功能:
$yourString = "text
with
enters";
$result = nl2br( $yourString );
print $result
// output:
// text<br>with<br>enters
查看docs
答案 1 :(得分:1)
$breaks = array("\n");
$com = str_ireplace($breaks, "<br />", $com);
切换位置的诀窍:)谢谢大家:)
答案 2 :(得分:0)
OMG !!!!!!!
$breaks = array("\n");
$com = str_ireplace($breaks, "<br />", $com);
经过大量搜索,效果很好!!!! ♥☻☻☻♥♥♥