PHP Remove string newline character example

Source: Internet
Author: User
Tags valid

  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);?>     
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.