The problem is the following, after adding a record from textarea to the database, the formatting remains, that is, line by line with hyphenation, but when outputting to the page, the entire record goes in 1 line. :( How to make a conclusion with saving lines?

  • In what format is the data in the database? More precisely, I am interested in which character is responsible for the line break? - Aries
  • @Aries Data is in varchar - Nikolay
  • The question is different, the line breaks in the database are as \ r \ n or as <br/>? And immediately, the next question, the data you then output just as the text on the page, or back to some textarea? - Aries
  • @Nikolay, the presentation of the problem is not a question. please make the necessary adjustments by clicking edit . - aleksandr barakin
  • @aries find it difficult to answer the first question, it seems like <br>, but what about the output, the entry is displayed as text on the page - Nikolay

2 answers 2

If my telepathic abilities do not deceive me and I correctly understand the essence of the problem =) Then you just need to use the nl2br function when outputting from the database, or before writing to the database. Example:

 $area = nl2br($_POST['area']); 

This function inserts a tag before the line feed (\ r \ n, \ n \ r, \ n and \ r) <br/> .

    When outputting from the database, before printing, wrap the text in the function nl2br();