nl2br

PHP: How to keep line-breaks using nl2br() with HTML Purifier?

馋奶兔 提交于 2019-12-21 17:56:41
问题 Issue: When using HTML Purifier to process user-inputted content, line-breaks are not being translated into <br /> tags. Consider the following user-inputted content: Lorem ipsum dolor sit amet. This is another line. <pre> .my-css-class { color: blue; } </pre> Lorem ipsum: <ul> <li>Lorem</li> <li>Ipsum</li> <li>Dolor</li> </ul> Dolor sit amet, MyName When processed using HTML Purifier, the above is being altered to the following: Lorem ipsum dolor sit amet. This is another line. .my-css-class

How to replace newline or \r\n with <br/>?

别说谁变了你拦得住时间么 提交于 2019-12-17 01:57:25
问题 Trying to simply replace some new lines. Have tried 3 different ways and I get no change: $description = preg_replace('/\r?\n|\r/','<br/>', $description); $description = str_replace(array("\r\n","\r","\n"),"<br/>", $description); $description = nl2br($description); These should all work but I still get the newlines. They are double: "\r\r". That shouldn't make any of these fail right? 回答1: There is already nl2br() function that replaces inserts <br> tags before new line characters: Example

Vue.js show white space (line breaks)

∥☆過路亽.° 提交于 2019-12-12 09:44:53
问题 How would I show line space in vue.js. Right now everything is after each other.... Already tried this: https://laracasts.com/discuss/channels/vue/vuejs-how-to-return-a-string-with-line-break-from-database But nothing seems work. Trying this for 3 days now -_-. I'm using Vue.js 1.0 and browserify . Thanks a lot! --EDIT-- <template> <div> <bar :title="title"></bar> <div class="Row Center"> <div class="Message Center" v-if="!loading"> <div class="Message__body" v-if="messages"> <div class=

Removing Break Lines

不想你离开。 提交于 2019-12-11 07:44:51
问题 I've asked this question before but I didn't seem to get the right answer. I've got a problem with new lines in text. Javascript and jQuery don't like things like this: alert('text text); When I pull information from a database table that has a break line in it, JS and jQuery can't parse it correctly. I've been told to use n2lbr(), but that doesn't work when someone uses 'shift+enter' or 'enter' when typing text into a message (which is where I get this problem). I still end up with separate

ignore pre tags when using nl2br()

馋奶兔 提交于 2019-12-11 06:59:12
问题 I want to ignore the following tags when using nl2br. I have standard pre, and also some specific pre tags that are styled. When i do this is sticks <br> tags inside the <pre> tags. string = "Here is some text <pre> <xml> <item></item> <name></name> </xml> </pre> That includes new lines and carriage returns what can i do to add <p> and <br> tags but not to the text below inside the <pre> tags </pre>. <pre class="brush: csharp; title: ;" title=""> public MainPage() { // select the culture (de,

PHP: How to keep line-breaks using nl2br() with HTML Purifier?

风流意气都作罢 提交于 2019-12-04 09:48:24
Issue: When using HTML Purifier to process user-inputted content, line-breaks are not being translated into <br /> tags. Consider the following user-inputted content: Lorem ipsum dolor sit amet. This is another line. <pre> .my-css-class { color: blue; } </pre> Lorem ipsum: <ul> <li>Lorem</li> <li>Ipsum</li> <li>Dolor</li> </ul> Dolor sit amet, MyName When processed using HTML Purifier, the above is being altered to the following: Lorem ipsum dolor sit amet. This is another line. .my-css-class { color: blue; } Lorem ipsum: Lorem Ipsum Dolor Dolor sit amet, MyName As you can see, " MyName "

Using nl2br to preserve textarea new lines to mysql… how to return data to textbox nicely?

你离开我真会死。 提交于 2019-12-02 20:04:50
问题 I have a form with a textarea whose results are inserted into a mysql database. I'm using nl2br to preserve the line breaks. However, because this inserts br's in the text, when a user goes to edit what they've entered in the textarea, it shows all the br's in the textarea which were saved in mysql (looks ugly for people who don't know html). So, if I don't use nl2br, the line breaks look nice when echoed back in the textarea but not saved in the database correctly. If I use nl2br, the line

Newline Conversion in Submitted Text in PHP

时光总嘲笑我的痴心妄想 提交于 2019-12-01 19:39:12
I have a system set up for users to submit their articles into my database. Since it will just be HTML, I don't want to expect them to know to type <br /> every time there's a newline, so I am using the PHP function nl2br() on the input. I'm also providing an article modification tool, which will bring their articles back into the form (this is a different page, however) and allow them to edit it. In doing this, the <br /> elements were appearing also (with newlines still). To remedy the elements appearing (which I had expected, anyway) I added preg_replace('/<br(\s+)?\/?>/i', "\n", mysql

How to use nl2br() to handle string with '\\r\\n'?

放肆的年华 提交于 2019-11-28 11:42:44
I am retrieving a product description value stored in database from admin through textarea upon form submit. When I select the description from database I get $description = $row['description']; and I would like to echo $description on main page like this: echo nl2br($description); but I see "\r\n" characters instead of making new rows. From what I've found here and on the net, your string must be used between double quotes, like this: echo nl2br("Hello, \r\n This is the description"); Now, the value of $description from database is in fact "Hello, \r\n This is the description" but in my

\\n vs. PHP_EOL vs. <br>?

别等时光非礼了梦想. 提交于 2019-11-28 04:42:32
In most cases, as for one interactive website, when we output multiple lines of contents to web client browser, in my opinion, <BR /> is much more preferable than other two: \n or PHP_EOL . Else, we need to use " <pre></pre> " to wrap the output content or use nl2br() to insert <BR /> before \n so as the multiple line mark can take effect in HTML. Like following example. $fruits = array('a'=>'apple', 'b'=>'banana', 'c'=>'cranberry'); // Multiple lines by \n foreach( $fruits as $key => $value ){ echo "$key => $value \n" ; } // Multiple lines by PHP_EOL reset( $fruits ); while ( list($key,