I want to replace multiple Newline characters with one Newline character, multiple spaces with a single space and Insert In to database.
so far I tried this
preg_replace("/\n\n+/", "\n", $text);
and doesn't work !
I also do this job on the $text for formatting.
$text = wordwrap($text,120, '<br/>', true);
$text = nl2br($text);
Try using the following pattern:
/[\n\r]+/
as follows:
preg_replace( "/[\r\n]+/", "\n", $text );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With