Home > Backend Development > PHP Tutorial > PHP code to replace special characters in extra long text

PHP code to replace special characters in extra long text

WBOY
Release: 2016-07-25 09:05:27
Original
1112 people have browsed it
  1. function unhtml($content){
  2. $content=htmlspecialchars($content);
  3. $content=str_replace(chr(13),"
    ",$content);
  4. $content=str_replace(chr(32),"
    ",$content);
  5. $content=str_replace("[_[","<",$content);
  6. $content=str_relace(") _)",">",$content);
  7. $content=str_replace("|_|","",$content);
  8. rerurn trim($content);
  9. }
  10. ?>
Copy Code

Attached: PHP str_replace() function

Definition and usage The str_replace() function uses one string to replace other characters in a string.

Grammar str_replace(find,replace,string,count) Parameter Description find required. Specifies the value to look for. replace required. Specifies the value to replace the value in find. string required. Specifies the string to be searched for. count optional. A variable counting the number of substitutions.



source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template