Home  >  Article  >  Backend Development  >  PHP text style implementation code that retains multiple spaces and line breaks

PHP text style implementation code that retains multiple spaces and line breaks

小云云
小云云Original
2018-02-12 13:34:092621browse

The function of blocking sensitive words when users submit forms. The sensitive words come from ciku.txt under the same path on the server side. The sensitive words are connected through "|", such as "g|c|a". When submitting the form, the sensitive words are replaced. More importantly, the username in the form text field needs to be maintained. Enter multiple spaces and newline styles and output them as they are. The php code is as follows:


');
  $message=preg_replace($pattern, $replace, $_POST['message']); 
  $cikuStr=file_get_contents('ciku.txt');
  $cikuArr=explode('|',$cikuStr);
  $liuyan=str_replace($cikuArr, "**",$message);
  echo '您的留言是:
'.$liuyan; } ?>


1 

  

The screenshot of the effect is as follows:

Related recommendations:

PHP replaces regular punctuation marks with spaces

Example of how to replace regular punctuation marks with spaces in PHP

Summary of various methods of using spaces in html

The above is the detailed content of PHP text style implementation code that retains multiple spaces and line breaks. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn