How can I trim multiple line breaks?
for instance,
$text ="similique sunt in culpa qui officia
deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore
"
I tried with this answer but it does not work for the case above I think,
$text = preg_replace("/\n+/","\n",trim($text));
The answer I want to get is,
$text ="similique sunt in culpa qui officia
deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore
"
Only single line break is accepted.
Also I want to trim multiple white space at the same time, if I do this below, I can't save any line break!
$text = preg_replace('/\s\s+/', ' ', trim($text));
How can I do both thing in line regex?