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);
\n,\ror\r\n. It depends on the system you are running this on.\r\n, Linux and Unix like systems tend to use\nand Mac OS tends to go for\r. You should really write your code to take into account all cases though. You should try to aim for platform independence where possible.