Home > Backend Development > PHP Tutorial > PHP compressed html function code

PHP compressed html function code

WBOY
Release: 2016-07-25 08:55:32
Original
1006 people have browsed it
  1. //Function name: compress_html
  2. //Parameters: $string
  3. //Return value: Compressed $string
  4. //by bbs.it-home.org
  5. function compress_html($ string) {
  6. $string = str_replace("rn", '', $string); //Clear newline characters
  7. $string = str_replace("n", '', $string); //Clear newline characters
  8. $string = str_replace("t", '', $string); //Clear tab characters
  9. $pattern = array (
  10. "/> *([^ ]*) * "/[s]+/",
  11. "//",
  12. "/" /",
  13. "/ "/",
  14. " '/*[^*]**/'"
  15. );
  16. $replace = array (
  17. ">\1<",
  18. " ",
  19. "",
  20. """,
  21. """,
  22. " "
  23. );
  24. return preg_replace($pattern, $replace, $string);
  25. }
Copy code


Related labels:
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