Questions tagged [nl2br]

PHP function that inserts HTML line breaks before all newlines in a string

PHP function that inserts HTML line breaks before all newlines in a string

string nl2br ( string $string [, bool $is_xhtml = true ] )

Returns string with <br /> or <br> inserted before all newlines (\r\n, \n\r, \n and \r).

Documentation: https://php.net/manual/en/function.nl2br.php

125 questions
2
votes
1 answer

When submitting to database from tinymce form it is adding \r\n

So normally I am not a big fan of text editors, but I am making some forums for a client and I am having a huge issue with it. I did not have this issue in Xampp but now that it is live it's going to have a ton of issues. Instead of wrapping the…
kira423
  • 325
  • 1
  • 5
  • 26
2
votes
1 answer

How to convert
to newline on Pre-populated textarea

I am having issues with
tags appearing inside of a pre-populated textarea form (with no breaks obviously). So these break tags need to be converted to /n within the textarea. This prepopulated text is being retrieved via the URL which also…
CSteel
  • 23
  • 3
2
votes
2 answers

Python Markdown nl2br extension

I'm a beginner programmer, and i've been trying to use the python markdown library in my web app. everything works fine, except the nl2br extension. When I tried to convert text file to html using md.convert(text), it doesn't see to convert…
Jamie B
  • 354
  • 1
  • 2
  • 12
2
votes
4 answers

Double line breaks with 'pre' tag and 'nl2br'

I used nl2br function for pre tags, but I've encountered a strange problem: there are 2 line breaks but there's only one
tag. For example: code in line 1
code in line 2
Displays as: code in line 1 code in line 2 instead…
Vahid
  • 382
  • 1
  • 6
  • 19
1
vote
2 answers

Line break in textarea

I am writing a form using php the form has a textarea and the data is sent to the script using $_POST; then stored into db. The problem is that when the textbox is populated and if the user do not press enter to make a new line break but he wait…
user1084304
  • 23
  • 1
  • 1
  • 4
1
vote
3 answers

ignore pre tags when using nl2br()

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
tags inside the
 tags.
string = "Here is some text

   
     
madphp
  • 1,716
  • 5
  • 31
  • 72
1
vote
1 answer

How to include new line and spaces in pdf creation using php?

I am trying to create a pdf document using php. But, I can't get new line in the pdf. nl2br is not working so I have used $newadd = nl2br(str_replace('\r', ' ', $inputSafe['address'])); Now I got the correct output in html as Naduvilachirayil…
1
vote
1 answer

how to make data from backend have breakline in frontend in vue?

i'm trying to achieve this. supposely i have data in backend with example: this data - #ghost\n#mik\n#bro supposedly it is store in an array of an object [ {hash:"#ghost\n#mik\n#bro"} ] i want to make the value of hash_tag to have breakline in…
1
vote
2 answers

Dealing with NL2BR from Database to HTML with Javascript

I am having difficulty with displaying HTML it seems. haha, let me explain. I have 1 template file for "comments"... and it tells things where to go and such in the html. When Adding, Updating and Selecting any of the "comments" IE:
Justin
  • 2,502
  • 7
  • 42
  • 77
1
vote
3 answers

Removing Break Lines

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…
Phillip
  • 1,558
  • 3
  • 15
  • 25
1
vote
2 answers

Why would \n\r appear if I used nl2br()?

Someone just made a group on my site which has a description with \n\r. The thing is that I already do this to the description text: //Convert all urls to links $group_description = preg_replace('#([\s|^])(www)#i', '$1http://$2',…
Genadinik
  • 18,153
  • 63
  • 185
  • 284
1
vote
2 answers

Cannot convert mySQL database entries text '\n' to '
'in Angular?

I can read data to my angular app from the database but I am just given the static \n in my text instead of a new line. I am aware I am supposed to convert all \n occurrences to
but I am failing to do this, even when using echo…
Mr Man
  • 93
  • 9
1
vote
0 answers

php nl2br not working with output of passthru and shell_exec

I have a program (written in cpp) which outputs some text lines. Each line starts on a new line. On the commandline this program works well. To test the code I used both fprintf (stdout, "some text\n"); and 'cout << "some text" << endl;' to produce…
iep
  • 601
  • 1
  • 8
  • 23
1
vote
0 answers

How to stop text from wrapping around image when using nl2br? overflow:hidden doesn't work here

I am designing a comment frame for a webpage I am working on. Upon using nl2br to ensure line-breaks aren't removed from stuff submitted from the the in the form, the text just wraps around the user image in the comment section (please see image).…
shelldon
  • 11
  • 1
1
vote
1 answer

How can I replace \r\n with a line break when I echo?

I am protecting my string using this code to insert it into the database: function protect($string){ $string = mysql_real_escape_string($string); return $string; } I then unprotect it using this code so that I can echo it out from the…
Yesterday
  • 561
  • 1
  • 15
  • 31
1 2
3
8 9