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
1
vote
1 answer

Laravel 4.2 br tags to nl in textarea makes double tags

so i have this problem with Laravel 4.2, that i have a textarea for updating the user profiles "about me", if i take it down from the database it works fine, i tried to do nl2br and hide the br tags, sort of worked aswell, problem is, when i write…
Defalt
  • 13
  • 3
1
vote
3 answers

Laravel nl2br() with sending emails

I'm using Laravel 5.3 and I'm trying to send an email with nl2br(). So I'm using the default email blade file that's new in Laravel 5.3 (vendor/notifications/email.blade.php) But it does not show line breaks. Only…
Jamie
  • 10,302
  • 32
  • 103
  • 186
1
vote
2 answers

Keep white space with htmlentities

Currently, this is my code $str = file_get_contents($sFile); echo nl2br(htmlentities($str)); How can I keep the whitespace (tab and multiple spaces) in the files when i output them? Example Input: if(a==b){ code more code } Should ouput…
mcky
  • 823
  • 2
  • 7
  • 20
1
vote
1 answer

How to convert a new line and a br into paragraph tag

A client of mine is using an old CMS and their database contains blog entries that used nl2br() on the frontend to give the illusion of paragraph spacing. On the backend, there is a simple textarea that allows you to add text. So for example if you…
Hugo
  • 441
  • 1
  • 9
  • 17
1
vote
1 answer

Safely store textarea input with newlines and preserve linebreaks

I have a problem storing a user submitted presentation in a database as a TEXT field. It shall not allow any HTML whatsoever but should preserve the linebreaks. So for example if the user submits an presentation like this from a form using a…
Markus
  • 616
  • 1
  • 9
  • 24
1
vote
1 answer

PHP ignore new lines that are blank characters when using nl2br

If the new line contains only blank characters or is an empty string, how can it be ignored when using nl2br?
user813077
1
vote
1 answer

Polymer: need paragraph text to break on lines

I've tried a couple different ways of doing this but I can't seem to get polymer to print the html or the breaks in the lines of the paragraphs (Need lines to break!). Pulling data via json call.
CarlosM
  • 79
  • 7
1
vote
2 answers

PHP NL2BR effect not as expected

I have a strange issue here, can anyone tell me why my nl2br does not seem to be achieving the desired effect? Here's the screenshot of the data as stored in mysql phpmyadmin: Here's a screenshot of my source code jquery / php code to display the…
aDvo
  • 894
  • 4
  • 15
  • 43
1
vote
2 answers

How to get the first paragraph bold in the php?

I am entering text in the database in two paragraphs first paragraph second paragraph I am storing them in my database and when I am displaying them on the frontend using nl2br it is getting displayed perfectly. I want the my first paragraph to be…
Rajeev
  • 115
  • 1
  • 10
1
vote
1 answer

nl2br returns
\r\n, how to make all built in PHP functions return \n instead?

Don't get me wrong, I'm not bothered about the pre PHP 5.3.0 xhtml
tags, and I can easily replace the \r\n with \n, of course. Thing is I want some sort of global setting on this pre PHP 5.3.0 server to make all similar built in PHP functions…
Henrik Erlandsson
  • 3,797
  • 5
  • 43
  • 63
1
vote
4 answers

Converting Newlines in JSON array to line breaks: JSON_decode and nl2br

I cannot get the below array to replace the carriage return and newline with an HTML break
JSON Array: {"Fruit":"Apple","Veggies":"Carrot\r\nCelery\r\n\r\nCucumbers"} I'm trying this and having no luck: $html =…
dabra904
  • 163
  • 5
  • 17
1
vote
1 answer


inserting space in next foreach item

I am actually making a spell checker. What is do is I split a string into words by space, add marks to ignore punctuation and a nl2br() function to keep the
s. Now, the problem is, when i say to ignore the br, it considers it as a word and even…
shahbaz
  • 372
  • 1
  • 3
  • 18
1
vote
2 answers

Does ZF have a filter for nl2br?

Does Zend Framework have a nl2br filter? I can't see it - am I just missing it? I imagine I could do the same thing with PregReplace...
DatsunBing
  • 8,684
  • 17
  • 87
  • 172
1
vote
1 answer

Excessive spaces caused by BBcode tables (PHP)

I've done extensive Googling, and I just can't seem to figure it out. Hopefully you can help me. I'm programming a message board. The system filters HTML out of replies, and forces my members to use standard BBcode instead. All of the basic BBcodes…
Connie
  • 77
  • 3
  • 8
1
vote
3 answers

Automatically Double Space Text Area

I have a text area that allows the user to input multiple lines of text. I would like to force everything in the text box to automatically be double spaced. I am using nl2br to output text and show the spacing. Lets say the user…
Brandon
  • 2,163
  • 6
  • 40
  • 64
1 2 3
8 9