I am using php5.3.6 and mysql 5.1.56 and CodeIgniter. Here is what I did.
Input some text in textarea, something like this:
what\'s this?
The Best Solution..
$insertdata = mysql_real_escape_string($string); (You can insert it in your database if you want)
$insertdata = mysql_real_escape_string($string);
echo stripslashes(str_replace('\r\n',PHP_EOL,$insertdata)); (The output is exactly as your input was)
echo stripslashes(str_replace('\r\n',PHP_EOL,$insertdata));