PHP three methods to remove carriage return and line feed

Source: Internet
Author: User
PHP three methods to remove carriage return and line feed
PHP three methods to remove carriage return and line feed

  1. // Line feed for different php systems
  2. // The implementation of line feed varies with systems.
  3. // \ N in linux and unix
  4. // \ R for MAC
  5. // Window \ r \ n to reflect the difference from linux
  6. // The Implementation methods on different platforms are different.
  7. // Php has three solutions
  8. // 1. use str_replace to replace the line feed.
  9. $ Str = str_replace (array ("\ r \ n", "\ r", "\ n"), "", $ str );
  10. // 2. use regular expression replacement
  11. $ Str = preg_replace ('// s */', '', $ str );
  12. // 3. use the variables defined in php (recommended)
  13. $ Str = str_replace (PHP_EOL, '', $ str );
  14. ?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.