To solve the problem of replacing line breaks with spaces, replace space with & amp; nbsp; line breaks with & lt; br & gt; doubt: replace space with & quot; whether the \ s line break is \ n or the \ r \ n environment is in a non-IR browser. Statement of solution, all replaced at one time. When the content is set to $ txt, it is difficult to replace the space of the PHPcode line break
I want to replace spaces
Replace line breaks
Doubt:
Enter "" or \ s as a space when replacing
Whether the line break is \ n or \ r \ n
The environment is in a non-IR browser
Internet Explorer does not need to be considered.
Statement of solution, all replaced at one time.
Set content to $ txt
------ Solution --------------------
PHP code
Echo preg_replace (array ('//', '/[\ r \ n] +/'), array ('','
'), $ String );
------ Solution --------------------
$ Changeset = array ('\ r \ n' =>'
', ''=>' $ Nbsp ;');
$ Str = strtr ($ str, $ changeset );