-
- //php line breaks in different systems
- //The implementation of line breaks is different between different systems
- ///n is used in linux and unix
- ///r is used in MAC // bbs.it-home.org
- //window In order to reflect the difference from Linux, it is /r/n
- //So the implementation methods are different on different platforms
- //php There are three ways to solve it
-
- //1. Use str_replace to replace newlines
- $str = str_replace(array("/r/n", "/r", "/n"), "", $str);
-
- //2. Use regular replacement
- $str = preg_replace('//s*/', '', $str);
-
- //3. Use variables defined by PHP (recommended)
- $str = str_replace(PHP_EOL, '', $str);
- ?>
Copy code
|