时间:2021-07-01 10:21:17 帮助过:36人阅读
<?php
header("Content-type:text/html;charset=utf-8");
if($_POST){
$pattern = array(
'/ /', //半角下空格
'/ /', //全角下空格
'/\r\n/',//window 下换行符
'/\n/', //Linux,Unix 下换行符
);
$replace = array(' ',' ','<br />');
$message=preg_replace($pattern, $replace, $_POST['message']);
$cikuStr=file_get_contents('ciku.txt');
$cikuArr=explode('|',$cikuStr);
$liuyan=str_replace($cikuArr, "**",$message);
echo '您的留言是:<br>'.$liuyan;
}
?>1<!--这是表单页面代码-->
<body>
<form name="message_board" id="message_board" method="post" action="timu.php">
<textarea name="message" id="message" cols="50" rows="10" >
"http://www.cnblogs.com/phpdream/"---勇往直泉
</textarea><br/>
<input type="submit" value="提交留言" id="submitMessage" onclick= />
</form>
</body>效果截图如下所示:


相关推荐:
PHP将标点符号正则替换为空格
php中标点符号正则如何替换成空格的示例
总结html中空格如何使用的各种方法
以上就是php保留多个空格及换行的文本样式实现代码的详细内容,更多请关注Gxl网其它相关文章!