how to auto break lines?

Discussion in 'PHP' started by ingilizdili, Oct 6, 2010.

  1. #1
    Hello;
    I send long texts into the database via a form which includes textareas. Then I want to get that content in a new file. However, there are very long lines which I can't limit either by table width or another method. I use <pre>...</pre> tags as well in the output file but that works as long as I manually break the lines while the text is still in the form, which is quite impractical as I paste the text into the textarea from another source, such as ms-word.

    Is there a method to limit the line lenght that is retrieved from the database?
     
    ingilizdili, Oct 6, 2010 IP
  2. GreenT

    GreenT Peon

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    GreenT, Oct 6, 2010 IP
  3. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #3
    Depends if theres a break in the words, I would just use wordwrap like above post said, or if there is space use nl2br

    Glen
     
    HuggyEssex, Oct 6, 2010 IP
  4. ilyakar

    ilyakar Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try the nl2br function:
    $text = nl2br($text_to_auto_break_lines)
     
    ilyakar, Oct 7, 2010 IP
    ingilizdili likes this.
  5. ingilizdili

    ingilizdili Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you very much. It worked perfectly.
     
    ingilizdili, Oct 13, 2010 IP
  6. sinha.sidhi

    sinha.sidhi Peon

    Messages:
    50
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    string wordwrap ( string $str [, int $width = 75 [, string $break = "\n" [, bool $cut = false ]]] ) this line is suitable for auto
     
    sinha.sidhi, Aug 29, 2011 IP