php - Removing Break Lines -



php - Removing Break Lines -

i've asked question before didn't seem right answer. i've got problem new lines in text. javascript , jquery don't things this:

alert('text text);

when pull info database table has break line in it, js , jquery can't parse correctly. i've been told utilize n2lbr(), doesn't work when uses 'shift+enter' or 'enter' when typing text message (which problem). still end separate lines when using it. seems correctly apply br tag after line break, still leaves break there.

can provide help here? message info jquery , send off php file storage, i'd prepare problem there.

this wouldn't problem normally, want pull of users messages when first load inbox , display them via jquery when select message.

you utilize regexp replace newlines spaces:

alert('<?php preg_replace("/[\n\r\f]+/m","<br />", $text); ?>');

the m modifier match across newlines, in case think important.

edit: sorry, didn't realise wanted <br /> elements, not spaces. updated reply accordingly.

edit2: @lainiwakura, made error in regexp, partly due previous edit. new regexp replaces cr/nl/lf characters, not whitespace character (\s). note there bunch of unicode linebreak characters haven't acknowledged... if need deal these, might want read on regexp syntax unicode

php line-breaks nl2br

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -