Hello, how to display text from the database without extra spaces and hyphenation?

I tried the function n2lbr - it does not help, you can do between two lines, at least 100 transfers

see screenshot enter image description here

  • So what do you need to do? - Roman Grinyov

1 answer 1

The answer is already here :

$string = trim(preg_replace('/\s\s+/', ' ', $string)); 

Alternative without regular expressions (all from the same place):

 $string = str_replace(array("\r\n","\r"),"",$string); 
  • the text in general is then displayed in many cases without hyphenation, but I just need to output it normally, as it is displayed here, in VC, on all sites, without extra empty space - turik97
  • Your question about “normal” is only your idea of ​​normality. Be specific, what do you mean by "normal"? The right question is half the answer, put it right, i.e. "there is this, this is how you need to turn it into an algorithm" - Daniel Protopopov
  • one
    I needed to display the text with a maximum break in 2 new lines, that's what I needed was $ text = nl2br (preg_replace ('~ (?: \ r? \ n) {2,} ~', "\ n \ n", trim ($ text))); - turik97
  • that's how records on the walls and private messages are displayed in VK, so I needed to - turik97