I am using the following to submit a post from a textarea to my mysql database in order to preserve single/double/triple line spacing on the output.:
$update = nl2br(htmlentities($string, ENT_QUOTES, 'UTF-8'));
Sometimes it works but sometimes a double is replaced with a single line space and other times double line spaces are preserved. Here is my output, all of this was input using double line spaces (hitting enter twice). Any suggestions on how to improve this would be appreciated:
something
went
a
little
wrong
there
Thanks Prinzhorn. Below is the CREATE TABLE statement for the table in question.
CREATE TABLE IF NOT EXISTS `ticket_updates` ( `id` int(11) NOT NULL AUTO_INCREMENT, `ticket_id` varchar(100) NOT NULL, `update` text NOT NULL, `time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `member_id` varchar(100) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=28 ;
My issue was caused by using
wordwrap()to try and format the output and NOT due to:I changed my
wordwrap($update, 50, " \n", true)to CSS3 properteyword-break:break-all;(word-break:break-word;would not work with IE9)