Answer the question
In order to leave comments, you need to log in
How to remove empty line breaks in html page code
Help solve the problem. I process the text in php using strip_tags(), then I cut /n /t /r using str_replace() but the text looks like this
The practice of using offshore companies in the world.
In the program:
Offshore, low-tax and prestigious European juris
How to get rid of these transitions so that the text looks like a single line in the page code?
The practice of using offshore companies in the world. In the program: Offshore, low-tax and prestigious European jurisprudence
Answer the question
In order to leave comments, you need to log in
$text = str_replace(array("\n", "\r"), '', $text);
works for me
There are simply no words ...
In general, first set the task for the future, and then solve it. Judging from the explanation, you do not need to remove "\n" and "\r", but replace any of their sequence with 1 space (most likely exceptions are possible, but only you know them). So, if any empty characters can fall under this, then you can write:
$text=preg_replace('/\s+/',' ',$text);# Replace all sequences of empty characters with 1 space
Or the same with enumeration in an array through str_replace (I would stop at the regular expression).
This code will replace any sequence of characters included in "\s" with 1 space.
And read the php help, because there it is written about the difference in " and ', and about the functions used in the example,
in short it looks like this
$text = strip_tags($row['text'],'');
$text = str_replace('\n','',$text);
…
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question