Summary of alternative line break methods in PHP
PHP replaces the line break method summary, PHP has three ways to solve.
1. Use Str_replace to replace line breaks
$str =str_replace (Array ("\ r \ n", "\ r", "\ n"), "", $str);
2. Use regular replacement
$str =preg_replace ('//s*/', ', $str);
3. Use PHP-defined variables (recommended)
$str =str_replace (Php_eol, ", $STR);
To the foreground can display the line break, nl2br the direction function reference PHP manual
$str = "ABEFC"; Echo nl2br ($STR);
The output HTML code is as follows:
A
B
E
F
C
Articles you may be interested in
- PHP uses regular filters to filter various tags, spaces, line break codes
- How PHP converts BR newline characters in HTML to line breaks in text input
- PHP compressed HTML page code (clear spaces, line breaks, tabs, comment markers)
- CSS control English, Chinese forced line and non-newline code
- PHP string substitution function str_replace faster than preg_replace
- PHP replaces only once, controls the number of replacements
- PHP compressed HTML page code reduces network data transfer, clear spaces, tabs, comment tags
- How to use Curl's post submission data in PHP and get a summary of how to get Web page data
http://www.bkjia.com/PHPjc/1072764.html www.bkjia.com true http://www.bkjia.com/PHPjc/1072764.html techarticle PHP replaces line break method Summary of the method of replacing newline characters in PHP, PHP has three ways to solve. 1. Use Str_replace to replace newline $str =str_replace ("\ r \ n", "\ r", "\ ...