PHP Remove string newline character example

Source: Internet
Author: User

  This article mainly introduces the PHP to remove string newline character examples, the following sorting out the common way to remove the line, the need for friends can refer to the following

The 1th way:   Code is as follows: <?php str_replace ("n", ", $str); ?>     2nd:   Code as follows: <?php Str_replace ("RN", ", $str); ?>     3rd:     Code as follows: <?php preg_replace ("/s/",", $str); ?>     Following instructions: First, say n,r,t N soft carriage return: The beginning of the line in Windows that represents a newline and returns to the next line in Linux/unix, but does not return to the beginning of the next line R soft space: in Linux/unix Returns to the beginning of the line at the beginning of the row, indicating the line break in Mac OS and returning to the next line. The equivalent of n in Windows T-jump (move to next column) Supplemental NOTE: They are valid in a string of double quotes or delimiters, and are not valid in a string of single quotes. RN is commonly used to represent the return key on the keyboard (Linux,unix), or only in N (Windwos), in the Mac OS with R to express enter! T represents the newline symbol in the tab file on the keyboard: Windows:n linux/unix:rn   The following code explains three common methods for removing line wrapping in the string in PHP   1, using the escape character function     code as follows: <?php $str = str_replace (Array ("/r/n", "/R", "N"), ', $str);?>     2, replace     code with regular expressions as follows: < ? php $str = preg_replace ('//s*/', ', $str);?>     3, the recommended use of PHP system constants   Code is as follows: <?php $str = Str_replace (PH P_eol, ", $str);?>     

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.