How to delete newlines in php: You can use the variable PHP_EOL defined by php, such as [str_replace(PHP_EOL, '', $str);]. You can also use regular rules to delete, such as [preg_replace('//s*/', '', $str);].
Specific method:
(Recommended tutorial: php video tutorial)
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); $str = str_replace(PHP_EOL, '', $str);
Related recommendations : php training
The above is the detailed content of How to remove newline characters in php. For more information, please follow other related articles on the PHP Chinese website!